Is my HTML clean enough?

All this talk about POSH (plain old semantic HTML) has got me thinking about how I build web sites. I seem to have been following the principles of POSH for a few years now:

  • Valid HTML;
  • Clean and well structured HTML;
  • Only use tables for tabular data;
  • Avoid presentational HTML where ever possible;
  • Use semantic ID and class names.

As well as trying to only use:

  • HTML for structured content
  • CSS for presentation
  • Javascript for behaviour

However, things do not always work out that simply. For example a site I built a few years ago has an excessive number of divs aka divitis. I did that on purpose, purely so I (and more importantly anybody who had to follow) would not have to deal with the different box models of IE 5/5.5 and everybody else. Even with this blog, the content is structured for ease of presentation and there are extraneous divs purely for presentational purposes.

The next incarnation of this blog will be better in how the content is structured, however, I will not guarantee that about extraneous divs for purely presentational purposes. The problem as I previously stated is that the design I want using my prefered faux columns method who require six separate background images for an elastic design. While I can do this with a single div and CSS3, the only browser that currently support is Safari.

The alternative are:

  • Use a table for this layout, I disagree with this method on principle as well as not wanting to spend the time necessary to relearn the skills required (seriously I have forgotten how to use tables for layout.)
  • Use the One True Layout which has it#’s problems.
  • Use javascript to get equal height columns. The main issue with this is that javascript is supposed to be for behaviour not for presentation.

If I was doing a site for work, I would have no qualms about using the faux column method and extra div elements for presentation. Because, it is the most efficient method for me to use at the current time. However, as this blog is about personal expression and that includes the underlying code, I will look at the alternatives more closely.

One Response to “Is my HTML clean enough?”

  1. Ben Buchanan Says:

    I think there has to be a balance between perfection and reality. In my work life I regularly put in extra divs based on long experience – even when they’re not being used now, I know they’ll be required at some point in future. In a large-scale environment you can’t rely on being able to add a div later on. It’s forward planning.

    That said, most of the time a good POSH structure with logical classes will actually have enough divs to go around.