WordPress and Adding Line Breaks – a Hack

January 9, 2008 · Posted in Nerdy Stuff 

I came across the issue of adding a line break on one of my pages. This page contains an iframe, which may or may not be the root of the problem. My goal was to have a couple of lines of text, space, camera image, space, and a couple more lines of text. I finally got there, but it took a little Googling. I tried using the regular tags; <br> and <br />, but they didn’t work. The original code for the iframe had the image being aligned to the left. By deleting the align code I was able to get the second line of text to move to the bottom of the frame. I still wanted an extra space under the camera image. After Googling for line breaks I stumbled on A Truth Seeker’s blog and copied this little snippet of code:
<br clear="none" />
That did the trick. I’m calling this a hack since I didn’t really bother with too much research. I just tried stuff until I got my line break. I’m also a lazy html’er. I only learn code when I want to do something. Please feel free to add your comment, especially if you know what the correct solution should be.

(Edit 1/14/09: Deleted the link to the Harley Cam. Sadly, that page no longer exists.)
(Edit 7/9/2010: Deleted the link to the Truth Seeker’s blog. It apparently no longer exists.)

Comments

24 Responses to “WordPress and Adding Line Breaks – a Hack”

  1. [...] strip out HTML tags and simply ignores return as line break. Anyway – a bit of googlage turned up this post: a shining lighthouse in a sea of confused bloggers. It turns out that the relevant code is: [...]

  2. foobar on December 9th, 2008 12:51 am

    It may be a hack but it flippin works. :)

  3. Chris on February 14th, 2009 12:36 pm

    Sorry, doesn’t work, just the same as a normal br tag and gets stripped out.

  4. SeVeN on February 14th, 2009 3:15 pm

    Well, Chris, I just tested it out and it works just fine.

  5. Andre Bluehs on March 1st, 2009 10:36 pm

    Looks like the reason this works is because however they are detecting the tag and stripping it for a tag, they miss it if it has ANYTHING inside it. This also works for me: . i assume if you just put something inside the tag, it ignores it.

  6. Rubayat on March 7th, 2009 8:38 pm

    I was also having a lot of problem with line breaks in wordpress. I found a small plugin that solves the problem.

    This might help your readers:
    http://rubayathasan.com/wordpress/plugin/enabling-line-break-in-wordpress/

  7. Craig on March 8th, 2009 10:19 pm

    I kind of accidentally stumbled across this. If you add the code

    <strong></strong>
    in where you want the line break it seems to work. Not a great solution, but the quickest i can think of

  8. Andy on April 8th, 2009 1:14 pm

    Unfortunately it doesn’t work for me either. WordPress just strips the code out. That’s what seems to be the problem, wordpress stripping any sort of line break code out.

  9. Andy on April 8th, 2009 1:21 pm

    Actually I just found that this works:

  10. Andy on April 8th, 2009 1:23 pm

    Whoops, try this maybe (node sure if “code” tags work in the comment field)?

    <br class="blank" />

  11. SeVeN on April 17th, 2009 4:20 pm

    Just an FYI to anyone wanting to post a comment; the “code” tags do work in the comment box. Thanks for everyone who has been contributing.

  12. Sebastian on June 5th, 2009 6:37 am

    Thank you so much for this little tip. It made my day alot easier.

  13. Nina on June 16th, 2009 8:56 am

    Thank you for posting this code. I worked perfect for me!

  14. Okoth on August 9th, 2009 9:44 pm


    is easier to remember though

  15. Okoth on August 9th, 2009 9:46 pm

    [code]
    [/code]

  16. Okoth on August 9th, 2009 9:47 pm

    can’t show the code…

    Good luck to you all!

  17. lockpro on October 4th, 2009 5:28 pm

    Use this, minus the spaces.

  18. lockpro on October 4th, 2009 5:32 pm

    sorry, this blog stripped out my code. Trying again.
    it is a p tag, a code tag, a br/ tag, a close code tag, and a p tag.
    Without the “<" it is;
    p code br/ /code p

    "

  19. REIT on October 6th, 2009 4:46 pm

    There is obviously a lot to know about this. There are some good points here. :)

  20. Curt Joel on October 24th, 2009 10:57 am

    THANK YOU FOR POSTING THIS!!! I’ve been searching for a for word press all morning! :( YOU are THE MAN :)

  21. Curt Joel on October 24th, 2009 10:58 am

    word press … (BREAK)…

  22. Gr on January 26th, 2010 2:22 am

    Works for me! Thx.

  23. myk on May 26th, 2010 11:29 pm

    Just add this before every paragraph

    <&nbsp />

  24. Ann Aguirre on July 9th, 2010 10:51 pm

    This was super helpful. I’ve been Googling for a while looking for a simple fix. This rocks! Thank you.

Leave a Reply