applying CSS styles to xml elements via class attribute

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • luke.crouch@gmail.com

    applying CSS styles to xml elements via class attribute

    My server-side php script is generating an xml response with the
    following structure:

    <thread class='Columns' >
    <Id class='Column dataDetail'>123 45</Id>
    <Command class='Column dataDetail'>SET </Command>
    ..
    ..
    ..
    </thread>

    I have CSS styles defined for Columns, Column, and dataDetail like
    so...

    ..Columns {overflow: auto; width: 100%; font-size: smaller}
    ..Column {position: relative; float: left; width: 100px; height: 20px;}
    ..dataDetail { border-top: 1px solid #c0dfc5; font-size: smaller}

    But these styles don't apply to the thread element and its children
    even though they have the class attribute. Do CSS class-specific
    selectors only apply to HTML elements? If I replace the xml element
    names with 'div' the CSS styles apply correctly.

    How can I make the CSS apply to XML elements with class atributes?

    Thanks.

  • David Dorward

    #2
    Re: applying CSS styles to xml elements via class attribute

    luke.crouch@gma il.com wrote:
    [color=blue]
    > <thread class='Columns' >[/color]
    [color=blue]
    > I have CSS styles defined for Columns, Column, and dataDetail like
    > so...
    >
    > .Columns {overflow: auto; width: 100%; font-size: smaller}[/color]

    The CSS class selector is a bit of magic that *only* applies to HTML
    documents[1]. Use the attribute selector instead.

    [class=Columns] { ... }


    [1] So not to generic XML documents, and not to XHTML[2] documents
    [2] XHTML documents served as text/html are not XHTML, they are broken HTML
    (confused? Yes. XHTML is silly).

    --
    David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is

    Comment

    • Michael Winter

      #3
      Re: applying CSS styles to xml elements via class attribute

      On 26/01/2006 00:00, David Dorward wrote:

      [snip]
      [color=blue]
      > [class=Columns] { ... }[/color]

      [class~=Columns] { ... }

      would more closely match the behaviour of class selectors with HTML.

      [snip]

      Mike

      --
      Michael Winter
      Prefix subject with [News] before replying by e-mail.

      Comment

      Working...