How to add line breaks in a WordPress post

January 16th, 2010 at 3:38 pm No Comments

Do you find it annoying that WordPress removes all of the <br /> tags from your post? Me too, so I did some research on how to fix this. I found a lot of wonky solutions, but I did find two worth mentioning.

First, you can install the TinyMCE Advanced plugin for WordPress. After this is installed, go into the TinyMCE Advanced settings and enable the option – “Stop removing the <p> and <br /> tags when saving and show them in the HTML editor”. And then you can add all the <br /> tags you want.

The second solution, which I like better is to use <br clear=”none” /> in your posts. This will work without any plugins. Now, a couple of things worth mentioning. If you put this tag on it’s own line in your post, WordPress will put <br clear=”none” /> and <br /> inside of a <p>, thus making it two line breaks. But if you use it on the same line as another sentence, it will only add one line break. Either way, you can control the formatting of the line breaks with CSS using something like this…


br[clear="none"] {
  margin: 5px 0;
}

.entry br {
  margin: 2px 0;
}

I hope this was helpful. Also, if you want to learn how to stop WordPress from automatically adding <p> and <br /> to your post, read my other post: How to control WordPress HTML formatting.

Leave a Comment