Re: CSS and XHTML

From: Ian Jacobs (ij@w3.org)
Date: Thu, Jan 11 2001

  • Next message: Eddy L O Jansson: "Small spelling correction."

    Message-ID: <3A5E5376.CC8750D0@w3.org>
    Date: Thu, 11 Jan 2001 19:44:38 -0500
    From: Ian Jacobs <ij@w3.org>
    To: pdf@bizfon.com
    CC: www-validator@w3.org
    Subject: Re: CSS and XHTML
    
    pdf@bizfon.com wrote:
    > 
    > In the "XHTML 1.0: The Extensible HyperText Markup Language" document, located
    > here:
    > http://www.w3.org/TR/2000/REC-xhtml1-20000126/
    > 
    > Appendix C (C.13) states:
    > CSS style sheets for XHTML should use lower case element and attribute names.
    > 
    > So then if my page contains this:
    > <style type="text/css">
    > BODY {}
    > #TOPTITLE {}
    > </style>
    > 
    > is that no good?  I'm not sure what the document 
    > means by "element and attribute
    > names" in a CSS document.  I can understand the 
    > element requirement to be lower
    > case (since html elements must be written in lowercase), 
    > but I don't know when
    > you would possibly specify an attribute name in a CSS 
    > document.  For the record,
    > my document validates with the above style.  
    > Should this validate?
    
    Here's my take:
    
    1) "All CSS style sheets are case-insensitive, except for
        parts that are not under the control of CSS. For
        example, the case-sensitivity of values of the HTML 
        attributes "id" and "class", of font names, and of
        URIs lies outside the scope of this specification. 
        Note in particular that element names are
        case-insensitive in HTML, but case-sensitive in XML. "
         -- CSS2, section 4.1.3
           http://www.w3.org/TR/1998/REC-CSS2-19980512/syndata.html#q4
    
        This suggests to me that:
    
        * CSS doesn't care whether you write "body" or "BODY" 
          because that's "outside" CSS.
    
        * When CSS is used in the context of XHTML, then
          case does matter, so you shouldn't use "BODY", because
          that doesn't match "body". 
    
        * Strictly speaking, it's not the validator's job 
          to detect that you have used BODY and should have used
          body. All the validator cares about is that you've put
          CDATA in the style element.
    
        * Perhaps an extra feature of the validator would be to
          validate that element and attribute selectors in
          xhtml documents were lower case. But that would require
          special case programming (though I don't know since I
          didn't write the validator).
    
    2) "CSS2 allows authors to specify rules that match 
       attributes defined in the source document."
        -- CSS2, section 5.8
     
    http://www.w3.org/TR/1998/REC-CSS2-19980512/selector.html#attribute-selectors
    
    
    - Ian
    
    -- 
    Ian Jacobs (jacobs@w3.org)   http://www.w3.org/People/Jacobs
    Tel:                         +1 831 457-2842
    Cell:                        +1 917 450-8783