Results 1 to 5 of 5

Thread: Interesting: W3.org says not to use DIV and SPAN for CSS

  1. #1

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032

    Interesting: W3.org says not to use DIV and SPAN for CSS

    From http://www.w3.org/TR/REC-CSS2/selector.html

    Note. CSS gives so much power to the "class" attribute, that authors could conceivably design their own "document language" based on elements with almost no associated presentation (such as DIV and SPAN in HTML) and assigning style information through the "class" attribute. Authors should avoid this practice since the structural elements of a document language often have recognized and accepted meanings and author-defined classes may not.
    So they are pretty much recommended not to do CSS by making a bunch of DIVs and SPANs and applying CSS class or id styles to them, but to stick with the standard HTML tags when possible, as those have established meanings.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    I agree with that in most cases, but occasionally it's so much easy to use multiple embedded divs and css with attached css than it easy to use the HTML presentation tags.

    This is a minor example but when I designing an XHTML 1.1 page, for our intranet, I wanted to use <BLOCKQUOTE> for displaying certain text. But, with this, I wanted to change font-size of a line of text embedded within so I opted for <SPAN STYLE="font-size:10pt;">. But, when I ran the page through the W3C Validator It told me the span wasn't allowed there. In the end I had to use a Div with embedded Spans which passed.

    In theory though, I agree with what they are saying, and in the vast majority of cases it should be agreed too.
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  3. #3
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    I think they just mean that you should only use DIV and SPAN when the enclosed markup has no stuctural meaning, e.g. use P for paragraphs instead of DIVs, acronym for acronyms etc. But the W3C don't follow their own rules anyway - look at their home page, they're using tables for layout

  4. #4
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    Yeah, good point. To me it still seems like the are saying that all presentation markup shouldn't be replaced with css.

    Yeah, I noticed the tables layout a while ago. Once CSS 3 is functional in all major browsers they'll have to changes... they've got no excuse then
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  5. #5
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Yep probably. Any idea of a rough date when CSS 3 is going to be finished? Mozilla already supports most of the working draft anyway doesn' it?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width