XHTML 2.0 -- A Chance to Improve Document Structure?

For some time now I've had a few nagging thoughts about the way HTML and
XHTML is structured.  Take for example the following (trivial) fragment

    <h1 id="food">Food</h1>
    <p>In this section I discuss my favourite foods.</p>
    <h2 id="cheese">Cheese</h2>
    <p>I adore many cheeses.</p>
    <h3 id="cheshire">Cheshire Cheese</h3>
    <p>Very nice, and one of England's oldest cheeses.</p>
    <h3 id="edam">Edam Cheese</h3>
    <p>A truly excellent savoury cheese from Holland.</p>
    <h2 id="potato">Potatoes</h2>
    <p>This is another food I'm enthusiastic about.</p>

Now, there's nothing wrong with it (apart from perhaps my dubious choice
of subject ;o).  You'll see I've neatly arranged my paragraphs alongside
different level headings.  The fact that (X)HTML is uncomplicated,
generic and highly flexible must be one of the reasons for it's success.

However, at the same time, I can't help but think the structure of the
document is rather flat.  The larger I make my document, the more it
seems to cry out for more hierarchical markup.

To illustrate my point, I repeat the example text using another XML
application -- DocBook.  This time the true document structure is much
more evident:

    <chapter id="food">
      <para>In this section I discuss my favourite foods.</para>
      <sect1 id="cheese">
        <para>I adore many cheeses.</para>
        <sect2 id="cheshire">
          <title>Cheshire Cheese</title>
          <para>Very nice, and one of England's oldest cheeses.</para>
        <sect2 id="edam">
          <title>Edam Cheese</title>
          <para>A truly excellent savoury cheese from Holland.</para>
      <sect1 id="potato">
        <para>This is another food I'm enthusiastic about.</para>

(One observation about the DocBook example: My ID's point to sections
and subsections, where as the XHTML example had ID's pointing to the
headings instead.  To make the XHTML version more like the DocBook, I
could have introduced <div> tags to contain the ID's.)

Here, then, are some ideas I would like to bounce off you all.  They are
my thoughts on a new way of structuring headings and sections in XHTML.

What would happen if <hN> elements were replaced with <sectN> elements,
and the role of the existing XHTML <title> element expanded to also
cover section titles?

Alternative solution -- a single <sect> or <section> element could be
used instead of the various <sectN> elements; it could be recursive
to allow it to be nested to any level desired.

In the present HTML or XHTML 1.X standards there's also nothing to
enforce sensibly structured headings; i.e. you can happily create a
level 2 heading and a level 4 heading with no level 3 heading between
them.  (ISO HTML has tighter rules than the W3C version it's based on,
and states that this practice isn't allowed, but even so I think the
suggestions above provide a more elegant solution.)

Of course, if "section tags" replaced "heading tags" entirely, some
would be unhappy about the reduced flexibility that results from a
more strongly enforced document structure.  However, section elements
wouldn't /necessarily/ have to make heading elements obsolute.

As a third and final example, <sectN> elements could be added whilst
preserving <hN> elements; a <hN> element would only be type-valid when
within a same-level section.  This would have the benefit of preserving
backwards compatibility with older user agents:

    <sect1 id="food">
      <sect2 id="cheese">
      <p>I adore many cheeses.</p>

Any thoughts?

Thanks for your time,


Received on Saturday, 24 March 2001 16:54:45 UTC