Structure is important too

The div tag: overused, underappreciated. People converted from tabular layout methods often stuff their pages with them, and ignore the fact that a more suitable (semantically speaking) element may be available: this has come to be known as ‘divitis’. Similarly named conditions apply for overuse of the id and class attributes. On the whole, people use it too much. Nevertheless, it’s an incredibly useful tag, and I’m not talking about its usage with CSS here either.

First, let me define ‘Structure’. I believe structure is how well your source code represents the document: if you have each document section markup up within a different tag, it’s an increase in the structural value of your document. Splitting your document into sections is a good idea: it helps you and other readers identify where one section ends and another begins.

A long time ago, Dave Shea talked about ‘Abstracting CSS‘: the article itself isn’t important, just the fact that he claimed:

Structural purists would like you to write markup that looks like so:


Personally, I strongly disagree with this. Why would a structural purist want a page that displays no inherent structure? Some would say that the structure in the above document comes from one tag following another. Indeed, this is what the W3C outliner goes on: header tags placed at strategic places in the document apparently give it structure.

In my opinion, no structure whatsoever comes from tag order. I’ve always thought that definition lists lack a bit of structure: it relies on pairing some dds with the preceding dt. Wouldn’t it be much simpler if paired dts and dds were wrapped in another tag? Structure is useful.

As I’ve just implied, tags exist in XML not just for semantic reasons but also for structural ones. How can we achieve structure in XML documents? How can we can get a document where the source is a rough outline of the document itself? Well, what tools do we have available? Just one: tags. Tags, wrapped in other tags, give structure (not just the appearance of headers). Nesting is one of the more powerful features of XML, you should use it rather than have everything as a top-level node.

Structural tags don’t make a great appearance in XHTML. There’s basically one: div. People are calling it a ‘hole in semantics’, which it is, but that’s missing the point. We’re not including this tag for semantics sake, we’re including it to give the document structure. Which it does beautifully; it splits up the document into chunks, and those chunks into further chunks, all without messing around with our semantic picture.

Don’t take the W3C outliner as law: headers aren’t the only way of achieving structure. Don’t damn the div tag, it’s in XHTML for a reason.