Sep 10, 2003

This past question has brought up some rather interesting points. Many readers chimed in on the fact that option B was better (wrapping the content in a p tag) due to nice formatting for un-styled viewers. Others saw it unnecessary, and more saw it fit to strip away that redundant div and style a p directly.

Billy was the first to get at a major point I was attempting to make with this question:

Put the line of text in a p, set it’s id to “footer”, and get rid of the div.

Ah ha. Exactly. If this is just one line of text, why not add the id directly to the p tag itself? p is a block-level element as well, and div is just a generic one. A good way to trim down that code: Look at what lies directly beneath your div tags. If it’s another block-level element, look into styling that next level — directly.

For instance, if you have a form that is wrapped in a div, it may be possible to get rid of the div and let the form be the block-level element.

Dan – just a note – with the newly colored sidebars, the text “SimpleBits is a place for Dan Cederholm to collect everything he does on the web.” on the front page is difficult to read…
Also, the sidebar coloring doesn’t show up in the comment preview window, making the Misc. block difficult to read as well.

Good piece, but addressis not for an address per se. The W3C states, “The ADDRESS element may be used by authors to supply contact information for a document or a major part of a document such as a form. This element often appears at the beginning or end of a document.” So address information is a bit shortsided.

After reading Dan’s conclusion then the best answer is ‘B’. Using the div and the p tag together gives the best results. If a paragraph gets added, nothing breaks and existing code does not need to be modified. The div allows easy styling in a regular browser and the p gives the needed result in the case of un-styled browsers. Using only one will require more changes when the time comes…and it usually does.
That brings up another thought. When a redesign occurs, how much change really happens? I would think that some of the content tags often get modified and not just the CSS which is the goal. The CSS Zen Garden shows its possible, but how often do we end up changing more than just the CSS to get results? If the original document is semantically correct then the original would only need to be changed in the case of missing or additional information and not too modify existing tags to help change presentation.

About SimpleBits

SimpleBits is the tiny creative studio of designer, author, and speaker, Dan Cederholm. I make websites and things for people like you. Occasionally, I also talk about them here. More →