September 10, 2003 · Dan Cederholm

SimpleQuiz › When to P › Conclusion

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.

Notable Comments

talon:

I consider div to be the "duct tape" of CSS - no semantic meaning, purely a wrapper for the grouping of block-level elements or for styling itself.

Michael Z.:

... if there's a chance in a million that your boss will decide next month that there must be second paragraph of fluff in the footer, then go with B.

Now that's forward thinking.

zlog:

What about <address>?

I hadn't thought of it, but it's a nice reminder.

jkottke:

... the responses in this thread are a good illustration of why "lorum ipsum" text should be used in such instances.

Heck yeah, and Ed Sharrer offers us the The Lorem Ipsum Generator.

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.

Oh, and extra credit goes to Doug Bowman:

I'd say the Charles DeMar he's referencing has to do with these three words: Better Off Dead.

Right on the money.

Summary

One line of text within a div could be marked up with a paragraph, without one, or tossed out in place of styling the p directly.

Some considerations:

  • Think about the future. Will this one paragraph likely turn into two or three? Maybe it's best to use a div.
  • If it's always going to be one, why not bag the div and add the id to the p tag itself?
  • Look into using address for ... well, addresses.
  • If you choose not to wrap a single line in paragraph tags, will this be ok for un-styled viewers?

See all past quiz questions and wrap-ups in chronological order.