Friday, May 25, 2007

Wordpress line break issue (<br /> , <br> & <p>)

So your awesome new Wordpress blog isn't doing line breaks (returns/blank lines) like it should after paragraphs and you need answers fast.

A "line break" is simply a blank line between sentences or paragraphs (much like the space between this sentence and the one above it).

I had this problem for about a week and it drove me crazy, I was sure it was a Wordpress problem until I discovered it was actually an issue with my theme.

Here are the symptoms ... These tags will not cause line breaks (returns) as they should :

<br />
<br>
<p>
</p>

Look inside your Wordpress theme css file and see if you can find something like this :

p {
margin:0px;
padding:0px;
}

If you do try removing it (only after making a backup of the code) and see if that works.

I had two instance of that type of code which was controlling how my post looked. After I removed the above type of code everything worked like a charm.

6 comments:

Anonymous said...

Tried all sorts of recommended hacks to /wp-includes/formatting.php and numerous other workarounds to this problem. None worked until I found this suggestion. It was indeed due to my theme's CSS. Thanks a million for posting...

Anonymous said...

Worked for me too! Driving me crazy. Thanks.
Steve

Anonymous said...

Awesome. I took out this bit of my theme's code:

{
margin: 0;
padding: 0;
}


Now I have decent looking posts.

TYVM

Unknown said...

Very good tip,
If you dont want to remove the reset css, I added to my main css file:

.post p {margin:0px 0px 10px 0px;}

That way you can keep the reset css line and just add margins to you posts..

mehdi said...

i tried but nothing happened.

wp said...

Its Worked for me,
That awesome and simple solution.
Thanks

//]]>