Anne van Kesteren

The subtle difference between markup and style

The latter has a style rule applied: white-space:pre-line.

(If rel="inspired-by" existed it would point to this forum thread.)

Comments

  1. Alas, I don't read Dutch. But one thing to be considered in thinking about your example is: are some semantics (content semantics, not markup-language semantics) lost if you disable CSS?

    For instance, if you were trying to present a mailing-address, you would not want the lines to run together if CSS were disabled or white-space:pre-line unsupported. So <br /> would be preferable.

    Similarly, if you were presenting a poem or song-lyrics.

    In each case, line-breaks are an integral part of the syntax of the content, and so should be reflected in the semantics of the markup.

    Posted by Jacques Distler at

  2. That is why I chose <br /> for my lyrics site rather than CSS.

    Posted by Robert Wellock at

  3. In the second example, the line break is presentational. In the first example, it is important for the meaning of the sentence/header/whatever. That is the difference.

    Perhaps my examples should be less abstract next time.

    Posted by Anne at

  4. The pre element is poorly defined in the HTML 4.01 specification, but rather well-defined in the 2004-07-22 draft of XHTML 2.0:

    The pre element indicates that whitespace in the enclosed text has semantic relevance, and will normally be included in visual renderings of the content.

    Therefore, it's all up to if the whitespace has semantic relevance or not.

    Again, the br element is poorly defined in HTML 4.01; however, it's non-existant in the 2004-07-22 draft of XHTML 2.0!

    Posted by Charl van Niekerk at

  5. I still get line breaks here with "user style" in Opera and "no style" in Firefox.

    Because of the PRE element, I guess? Is the PRE element equivalent to white-space:pre; ?

    I tried to test a style attribute in this comment, but your machine won't let me.

    Posted by Jan Egil Kristiansen at

  6. Charl, the PRE element is white-space:pre and has nothing to do with the issue at hand.

    Jan, the above are code examples. Not examples of rendering. And no, I will never allow the STYLE attribute in comments. Actually, I will try to avoid it when I can and do not need a quick fix.

    Posted by Anne at

  7. Anne: Sorry, I realise that now. I think I misunderstood your article a little. You should be a little less minimalistic on your accompanying text in your posts for those of us that don't want to read a 10-page thread. :-)

    I just throught about something else: XHTML 2.0 has the l (line) element replacing the br element which is very nicely defined too!

    Posted by Charl van Niekerk at

  8. And thank god XHTML 2.0 has <l>, because the <br/> semantics are just as useless as the <hr/> semantics.

    Posted by Sjoerd Visscher at

  9. And the presentational <hr/> element will be replaced by the semantic <separator/> element. :)

    Posted by zcorpan at

  10. The XHTML2 seperator element is just as poorly structured as hr though, even if it is a semantically better name.

    Posted by Lachlan Hunt at

  11. But more difficult to spell for native-English speakers, I gather? ;)

    Posted by Tommy at

  12. If rel="inspired-by" existed it would point to this forum thread.

    Have you thought about rel="related"? Arve has an interesting post about this today.

    Posted by Chris Hester at

  13. I have. It is not really related though and not really relevant for the discussion here either although some people only seem to understand my post after reading it. :-)

    Posted by Anne at