Anne van Kesteren

Abstracting HTML?

Robbert Broersma told me that in his opinion abstracted HTML is better than HTML with CLASS and ID attributes specified. Remember Abstracting CSS? He likes the first markup example better... My own example:

<body xmlns="" xml:lang="en">
 <p>A long text here...</p>
 <p>A long text here part 2...</p>
 <p class="note">This is a demonstration</p>
 <p>A long text here part 3...</p>

Do we lose information if I left the CLASS attribute out? I would say yes. If I understand Robbert correctly, he would say no he would say yes :-).


  1. If you truely abstract XHTML you should use:

    <p anne:type="note">This is a demonstration>/p<

    At least, that's my opinion :-)

    Posted by Mark Wubben at

  2. But it's application/xhtml+xml right? So why can't we make up our own semantically rich element?

    <note>Hi there</note>

    Posted by David house at

  3. Now, it may not be intuitively obvious, but those classes and ids provide the loosest possible coupling of presentation and content. Completely separating them is impossible! The content may not need the presentation, but the presentation without content is nothing. This pedantic obsession with separation of the two is a red herring.

    If you just take an HTML document and style it using only its hierarchy and no hooks, what happens if it gets nested within a larger context? Everything goes to shit, that's what; you have to rewrite ALL your hundreds of selectors. This is not true abstraction. It may look abstract because the HTML is very slightly cleaner, but don't be fooled. Now you've just gone and created the opposite problem: moving semantic information into your stylesheet! The selectors now contain incredibly specific hierarchical information that really has nothing to do with presentation. Obviously some presentation does depend on hierarchy, like nested lists or first-children, etc, but this is not one of those cases. The only reason to do it that way would be if you are the HTML author and someone else has to write the CSS.

    The reason we're having these discussions is because HTML was so bastardized by the browser wars and slow development and adoption of CSS that standard practices are incredibly kludgy and horrible. Now that we've made such progress there's no reason to go to far and push things to the point of absurdity.

    Let us focus on the important things: sensible standards, proper browser support, and good tools.

    Posted by Gabe at

  4. To answer the first two comments, what do you think about XHTML and RDF. I really like it although. Although I have to agree with the comment of Ian Hickson, that it complicates XHTML by the use of namespaces.

    Gabe, I very much appreciate your comment (I want writing skills like that myself :-) )

    Posted by Anne at

  5. I agree with Gabe, but I would take the idea a little further: Classes and ids should be used to indicate relationships between the things marked up in a document. For instance, I believe that the following:

    <p id="note" class="personal comment">I love roses</p>

    Should corrospond to the RDF triples:

    html-file#note rdf:type css-file#personal
    html-file#note rdf:type css-file#comment
    html-file#note rdf:value "<p>I love roses</p>"

    In essence, id and class attributes (along with hyperlinks) should define an ontology for the document. This is simular to the grammar being defined by (X)HTML and the presentation being specified by CSS.

    Of course, that's my worldview right now... :-)

    Posted by Jimmy Cerra at