MyBB Community Forums

Full Version: CSS styling of paragraphs
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a technical reason why the paragraphs in posts are styled with two line break
<BR>
tags instead of each being enclosed in paragraph
<P>
tags in the usual way?

I would like to adjust the space between paragraphs in posts but line breaks seem to be difficult/impossible to style with margin or padding settings in CSS.

Is there any way to edit the PHP code so that paragraph tags are used instead?

Thanks.
Because they're not 'paragraphs', they're just line breaks in text. You press Enter twice to get it onto a new line with a clear line between, so that's what the HTML is, two line breaks. Seems all forum software (at least vB/IPB/phpBB/SMF) does it exactly the same too, has <br /><br /> instead of trying to wrap things in <p> tags.
So what do you define as a 'paragraph' and when would you use the paragraph tag? If not to create space between blocks of text?

I guess boards format posts this way because the text of the post originates in a text editor/box?

But in HTML terms a line break is only meant to move text onto the line below - and you hardly ever need to do that. It isn't intended to create a new paragraph - which is what happens when you put two line breaks together.

This is a line
with a break.

And this is a new paragraph.

In the stylesheet you can control paragraphs like this:

div.yourcontent p {
margin: 0 0 10px 0;
padding: 0 }

But margins and padding don't seem to work well with the line break tag so it is difficult to style and space the text in posts when they are tagged in this way.

I acknowledge that other board software probably does it the same but that doesn't mean it's good coding Wink

When I first started coding in 1997 I used line breaks in this way with transparent GIFs to space the paragraphs, because it wasn't possible to control the margins/padding around paragraph and heading tags in those days. But CSS changed all that a long time ago.
Content of a post is never defined as a paragraph and the <p> tag is never used in posts, it just takes what you put in and parses it, it uses nl2br() to change new lines to <br /> tags. I mean if you edited the code to put a <p> at the start of the post, a </p> at the end, and then perform a str_replace on the post to change <br /><br /> to </p><p> that might work, but you'll probably find it won't work on all posts, depending on how many line breaks the users uses, if they even intend it to be a new paragraph at all.