March 19, 2004

Let's have a little look-see at XHTML 2.0, shall we?

First up, we have <blockcode>. This will come in handy, since it beats <code class="block">. (<code> is an inline element by default.)

Then we have the <section> and <h> elements, and the suggested deprecation of <h1> through <h6>. A basic document structure in HTML:

<h1>Main title</h1>

<p>First paragraph of the main title.</p>

<p>Second paragraph of the main title.</p>

<h2>Sub title 1</h2>

<p>First paragraph of first sub title.</p>

<p>Second paragraph of first sub title.</p>

<h2>Sub title 2</h2>

<p>First paragraph of second sub title.</p>

<p>Third paragraph of the main title.</p>

But wait a minute. How do we know that the last paragraph "belongs", if you will, to the main title? With XHTML 2.0, you'd nest <section> elements. The level of nesting indicates the importance of the <h> embedded somewhere in there, thus allowing arbitrary levels of headings (no longer restricted to six levels):

<section>
  <h>Main title</h>

  <p>First paragraph of the main title.</p>

  <p>Second paragraph of the main title.</p>
    <section>
      <h>Sub title 1</h>

      <p>First paragraph of first sub title.</p>

      <p>Second paragraph of first sub title.</p>

      <h>Sub title 2</h>

      <p>First paragraph of second sub title.</p>
    </section>
  <p>Third paragraph of the main title.</p>
</section>

There. Now the last paragraph has a proper parent. Or sibling, depending on how you view it.

I don't yet know where I stand on the deprecation of <h1> through <h6> issue. On one hand, it would be nice to be able to choose your style. On the other hand, XHTML 2.0 isn't supposed to be backward compatible with any previous version of HTML or XHTML (HTML 2.0, HTML 3.2, any flavor of HTML 4.0 and HTML 4.01 (Strict, Transitional and Frameset), XHTML Basic, any flavor of XHTML 1.0 (Strict, Transitional and Frameset) and XHTML 1.1).

Oh, and <l>, which stands for line. This'll be used to mark up lines of text, like a poem or a piece of computer code. Doing it like this (as opposed to using <br>), will allow you to automatically add line numbers. To quote the specs:

"By retaining structure in text that has to be broken over lines, you retain essential information about its makeup. This gives you greater freedom with styling the content. For instance, line numbers can be generated automatically from the stylesheet if needed."

Source: www.w3.org/TR/xhtml2/mod-inline-text.html#sec_9.7.

It's pretty cool, but you can do something similar, today, in HTML, using list items and some CSS. Check out Simon Willison's Numbered Code Listing Experiment.

<q> is now <quote> and it's now the author's responsibility to add quote marks, not the UAs'. Otherwise, there are no differences between the two.

This is far from a comprehensive look at XHTML 2.0, it's just scratching the surface a little.

<< | Previous entry (March 14, 2004) | Next entry (March 20, 2004) | >>
Back to Archive