P vs BR

Links | XHTML - 07/11/2006 @ 20:44



Should I use p or br?

The p element marks up a paragraph of text. A paragraph is one or more sentences that deal with a single thought.

A line break (br) is mostly a presentational tool, and should be handled by CSS rather than HTML. However, there are a few cases where line breaks can be said to have semantic meaning, for instance in poetry, song lyrics, postal addresses and computer code samples. These can constitute legitimate uses for br, but using br to separate paragraphs is definitely an abuse of the br element.

On the other hand, p has a very clear semantic meaning: it denotes a paragraph. Sometimes web authors tend to treat p as a generic block-level container element, but that’s not correct. It’s not uncommon to see a label and an input field wrapped inside a p within a form, but I would argue that it’s semantically wrong. A label and an input field do not constitute a “paragraph”.

(via)


Commenta | Leave a Reply

CommentLuv Enabled
***