Why a divless page?

08 October 2005, 19:24

Well, your a div, and your on that page - Tina

Being semantically meaningless divs add little to the page, other than to provide holders and separators (dividers, in fact!) for CSS to hook onto and making it easier for the page's stylist (the CSS developer) to accommodate the designer's requirements.

What divs do add however is page weight (admittedly not much, but it all adds up - as anyone not using broadband will tell you), and confusion when trying to read the markup. Nesting the divs worsens the issue exponetially. I'd imagine also that nesting items in a page slow the browser rendering down as well, but thats an incredibly minor concern nowadays with strict doctypes, highly optimised mature browser engines and speedy CPUs.

The solution is to use divs only when semantically meaningful markup is not possible. For example, if a design calls for a fixed width centred design, your going to have to wrap the lot in a div. This approach ensures that every byte of your code oozes semantic meaning to screenreaders, search engines, and people without CSS support.

Now after saying all this, I can think of an instance where extra divs are a good idea. I'm working on a project where standardised HTML coming out of a CMS is used in multiple designs. The designs are crazy. I don't mean that in a bad way, in fact they are extremely good, but designed for children and therefore have to be appealing to their hyperactive, ADD-addled brains. In order to adapt the HTML to the designs we had to add divs all over the show. Too many for each individual design, but enough so that we knew we would be able to target specific elements in other designs and also whatever the designer's requirements are in the future.

Worry ye not if you have divitus - XHTML 2.0 is coming (not anytime soon though). section will be your friend - think of it as a semantically meaningful version of a div. Checkout the use of this with the new h tag on the spec - its going to be CSS heaven I tell you.

Jason Cartwright RSS Feed

about

Jason is a freelance web developer based in London.

My clients include numerous startups, Google, YouTube, FHM, Nickelodeon, Volvo & the BBC.

I also co-own Ferrago Ltd, who publish videogames content to around 7m consumers monthly.

links

me

colophon