How To Force Line Breaks In WordPress Documents

computerkickTrying to add line breaks in a WordPress document using traditional methods like hitting enter multiple times, adding <br> tags in the HTML editor, or even adding additional paragraphs using <p></p> tags does not work. I can only assume that you have realized that, because you’re here now looking for a solution – no one wants all of their content to be smooshed together against their will. The good news is that there is a way to force line breaks in WordPress, and it’s so simple that it might make you chuckle.

WordPress, a very ‘smart’ platform, is so smart that sometimes it tries to think for you. So, when there is a lot of space in a WordPress document with no content, it will automatically strip the content-less code to make things cleaner and to improve efficiency.
 

How sweet of WordPress :-)
 

The problem is that human authors actually want that spacing when we deliberately put it there! So, like anyone else who is too smart for their own good, we simply have to trick WordPress into giving us what we want by superficially satisfying it’s requirements.
 

In English, we’re going to fool WordPress into thinking there is content where it really isn’t.
 

All you have to do to force line breaks in a WordPress document is add a non-breaking space before the line break code (in the HTML editor, of course). Do this for every line break that you want, for as many as you want:


&nbsp;<br>
&nbsp;<br>
&nbsp;<br>

 

WordPress thinks that there is content on those lines because technically there is, it’s just invisible content! It’s only a non-breaking space, but it’s enough to qualify as a line of content. If this tip helped you, please leave us a comment as a way of showing your support.
 

Thanks for reading, and happy blogging :-)

 

[NOTE] If you use the forced line breaks in your WordPress document, you will have to edit that document in the HTML editor from then on or WordPress will strip the line breaks. I know it stinks, but hey – WordPress is just trying to be helpful, right? :-P

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Facebook
  • Digg
  • del.icio.us
  • StumbleUpon
  • Squidoo
  • LinkedIn
  • MySpace
  • Technorati

12 Responses to “How To Force Line Breaks In WordPress Documents”

  • Mark says:

    Thanks for this – sorted me right out

  • Chris says:

    Nice. Except the next time someone clicks on the visual editor for WP, your line breaks are gone again.

    Yes, WP deliberately seeks out and deletes that “invisible content.” Why? It’s so infuriating.

  • admin says:

    WordPress is just trying a wee bit too hard to be helpful :-P

    And you are definitely right about the fickleness of the forced line break – if you don’t continue to edit the document in the HTML editor, the visual editor will strip the line breaks, taking you back square one. I will add a note to the end of the original post to make new readers aware of that before they use the method.

    Thanks!

  • Dina says:

    I found this while searching for a “fix” — I like this better :)

  • Cris Buckley says:

    Thank you so much! I’ve been so frustrated with not being able to get in the returns that I wanted, and I was doing everything you described–hitting return a lot, adding and . So, may I tell you I’m THRILLED with a solution?

    I had a blog hanging that I wanted to post tomorrow–but it looked so nasty all smooshed together that I just couldn’t do it. It’s looking good and ready to go now!

    Will have to tell my theme people that it’s not them–I had posted in the forum, thinking the problem was the theme.

    Thanks again!

  • latecomer says:

    I know this is old, but I have solution that survives the visual editor as well:

    Put this instead of br:

     

  • latecomer says:

    Ok it all disappeared because of html-tags so I’ll try again

    I know this is old, but I have solution that survives the visual editor as well:

    Put this instead of br:

    <div style=”height:50px”>&nbsp;</div>

  • latecomer says:

    Sorry, after further test: no it didn’t work

  • Thia says:

    Thank you for this! :)

  • Jack says:

    The paragraph tag does work from what I’ve tried. I guess maybe you need a space in it as shown here?

    http://www.theblogaholic.com/2011/01/16/add-line-breaks-in-wordpress-posts/

  • Thanks a lot. Still a little tricky as stated above, but it helped me, in the end, to add line breaks. Fantastic. I will add a link to this post.

Leave a Reply



Tip Jar

If this blog has helped you enjoy your Wordpress experience, show your love!


Contact Us!