Don’t use in your code

Many years ago, I was turned onto XHTML. Admittedly, without a full understanding of why. At the time, I was hardly in a place to object or complain, and did as I was told.

In the years since then, I’ve come to appreciate the reasons: cleaner, tighter code; better compliancy with standards; better semantics; and most importantly, separation of structure and presentation.

One of the things that XHTML does well is drop support for presentational tags, such as bold, italics, and my personal favourite, font among many. Okay, yes, technically they’re still in the XHTML 1.0 specification, but they’ve been deprecated. That’s enough for me to call them unsupported.

Right now, the
tag is still supported, being wholly valid. For the last few years, I’ve sat on the fence with what to do with it. According to the W3C, who defines this stuff, it’s good. So if I’m to follow the rules, I would allow use of br.

After today’s session in “HTML to XHTML” (with Molly), I had a bit of a revelation that really sealed the deal for me. As much as others love br for solving problems, there is really no reason to use br, except for legacy reasons. Otherwise, I think it’s time for br to be retired from the active tag list.

What was the revelation? Show me the semantic meaning. Every “good” tag in XHTML has semantic meaning, offering more to the structure of the page than the content it contains. For example, p is a paragraph — there’s nothing else it could be. br is a line break — a presentational construct, nothing else. There’s nothing else it could be.

Now I know that argument isn’t wholly suitable. Under that same argument,

would be removed from the list as well -- it doesn't offer any semantic meaning, as it is just a block-level element for breaking up the document. The same goes for .So maybe it's more than that. Maybe we need to consider tags in terms of semantics and document construction. That would allow most tags, with three exceptions: br, object tags (object, embed, img), and hr.

The object tags we have to allow -- they're partly presentational, but they do include content. Naturally, this means an extension of supported tags to include:

  • Semantic
  • Document construction
  • Content objects

Now I just seem to be finding ways to avoid including br. To a degree, I am, mostly because I want to see its use terminated. I know there are proponents out there who still think br has value. However, in places where you need a line break, it is usually because of formatting.

CSS handles the formatting now -- there's no reason to insert a tag to handle that aspect. So what if you need to create a series of individual lines, like with a poem? br would be perfect for that. That might be a reason for a specific XHTML structure, as that kind of content would require different semantics than regular structures (such as paragraphs).

Mind you, this also brings hr into question. Like br, this seems to serve only a presentational purpose. Yes, you can style it through CSS, even make it disappear. What is its purpose from a semantic perspective?

So br is finally off my "supported list" (just gimme a while to modify the WordPress template to remove it from the rendered code), only to be replaced by hr. Any votes with what to do with it?

Leave a Reply

Your email address will not be published. Required fields are marked *