Attention: We are retiring the ASP.NET Community Blogs. Learn more >

HTML philosophy: <br /> vs <p></p>

I decided that perhaps I should rewrite my text parsing engine for POP Forums from scratch instead of trying to band-aid it over and over. So with a clean slate, I have a few decisions to make.

I've noticed that other forums don't get into parsing paragraph tags at all. Instead they use line breaks for everything. What do you think, is this acceptable? If my understanding of XHTML validation is correct, it's OK as long as it's nested within some kind of block element, like <div>. It's certainly a lot easier to parse line breaks instead of properly closed <p> tags, that's for sure.

What's your take? I don't get religious about these things the way some people do, so I'm easily influenced.

9 Comments

  • My feeling is that if it's a paragraph it should be wrapped in &lt;p&gt; tags.



    Line-breaks are for things like lines of poetry, where a carriage-return is necessary, but it doesn't represent a new paragraph in the traditional sense.



    I do tend to get religious about these things, though :)

  • I say, go with what works. I'm like you, I don't get religious on this. If it'll be easier for you to use &lt;br /&gt; tags, and the end result is the same as though you used &lt;p&gt;&lt;/p&gt; tags... then I'd say go for it. The only reason not to is if you take HTML purity very seriously.

  • If you wrap your paragraphs in &lt;p&gt;&lt;/p&gt; tags instead of using &lt;br /&gt; at the end, you have way more control over the formatting.

  • Paragraph's are very nice too support, you can use some funky css to do whatever you want with them ...



    &lt;br /&gt; Is what I want most of the time in forums while typing my text though.

  • I believe a paragraph tag is a block element, whereas a br tag is an inline element. BR tags are for forcing line breaks, whereas with P tags you can control the spacing between paragraphs using CSS. The purist would probably say wrap paragraphs in P tags, but that's much more difficult since non-empty tags must have end tags to be well-formed (although all browsers don't require a closing P tag, they just assume one when they encounter the next opening P tag).

  • I've been using the

    method for years. I don't use the tag at all. It's probably time I make the switch.

  • I have found through use that, by default, Paragraphs tend to leave excess space before and after them, this can be a bit annoying when one is interested in very precise spacing. I use DIVs to wrap such elements without these spaces and prefer Breaks and Double Breaks within them. We therefore have some very tightly wrapped text with little to chance. I say "chance" because different browsers treat paragraphs slightly differently.

  • Years after I wrote this post, I'm firmly in the make P tags camp. With CSS you can do whatever spacing you want.

  • Thanks for the help and experience...

Comments have been disabled for this content.