5 ms·
Funny how they answered a question about paragraph tags that I was wondering yesterday. Most answers to the "p vs br" question seem to be "do whatever you want"
by ravenstine 10y ago
Funny how they answered a question about paragraph tags that I was wondering yesterday. Most answers to the "p vs br" question seem to be "do whatever you want", but the recommendation in the article seems most correct to me, since p tags are for the parser(in case it needs to know what the paragraphs of the body content are) while breaks are presentational.
- ianbicking 10y agoI think the bigger concern is that br tags don't fit the general box model. You can have CSS like p {margin-top: 2em}, but br is more like a newline, tied to the text flow itself. Which, as noted in the article, is okay if you are trying to just affect text flow, as in a poem with explicit line breaks. But actually trying to understand "what is a paragraph" using the semantic markup is probably a fool's game. What IS a paragraph anyway? There's not many automated tools that could make any use of that very semantic definition.
- acbabis 10y agoScreen-readers can iterate and skip paragraphs. If you have an article and you group your sentences in paragraphs, the document is easier to navigate. Paragraphs would also be helpful if you wanted to write a script to export an HTML document to LaTex/Word/ect as those will automatically indent paragraphs for you.
- wtetzner 10y agoKnowing which things are paragraphs would also make implementing things like Readability easier.
- greggman 10y agoI'm curious if you should use p at all. Unlike most other tags p doesn't not enclose block elements. So easy to break. Soooo many bugs related to starting with a paragraph, embedding something inside it, not realizing the content past whatever was embedded is no longer in any paragraph
- wruza 10y agoNice point here, despite its gray color. Paragraph is an atomic entity (irl), not a block of things. Inserting elements into paragraph is like inserting into an image; nonsense in many cases. If you want to apply css to some paragraphs, just put some divs/spans in there.