Skip to main content
WordPress made easy with the drag & drop Total WordPress Theme!Learn More

Create A WordPress Line Break (br) Shortcode

Last updated on:

Want to some extra spacing to your blog post using a line break in the WordPress visual editor? You can insert a break using the typical <br /> tag via the text editor, however if you add more than one they get stripped. Sometimes you need a bit of space, so having your breaks removed or turned into a paragraph just won’t do.

If you are one of many people struggling with this issue don’t worry because today’s daily code trick will allow you to use line breaks whenever and how many times you feel like it.

The Line Break Shortcode for WordPress

Simply insert the following shortcode code into your child theme functions.php file (if you’re not sure how to create a child theme, checkout our complete WordPress child theme guide):

/* ------- Line Break Shortcode --------*/
function line_break_shortcode() {
	return '<br />';
add_shortcode( 'br', 'line_break_shortcode' );

Add Line Breaks To Your Posts

With the code added to your functions.php file now all you have to do to create line breaks in your visual editor is to insert the shortcode wherever you want a space.



This is some text.
This is some more text after a line break.
This is even more text after adding two line breaks.

Which should display as:

This is some text.
This is some more text after a line break.

This is even more text after adding two line breaks.

How to Add Line Breaks To WordPress Posts Without A Shortcode

If you weren’t looking for a shortcode but just a way to line breaks you’re in luck. There other options for adding line breaks to your WordPress site without creating a custom shortcode.

The Simple Way to Add Line Breaks to WordPress

An easy option is to just hold the shift button and click enter. This will push your text to the next line as you’re typing (as opposed to clicking enter which would just create a new paragraph). A quick & easy solution!

Note: this will only work for one line break. Adding two or more breaks will simply result in WordPress forcing your text into a new paragraph. So if you want to create large gaps between content use the shortcode method or you can add a bit of CSS.

Add Large Line Breaks with Inline CSS

If for some reason you want a huge gap, then you could enter CSS right into your post. When creating your post click on the “text” tab in the top right corner to open up the HTML side of your post editor.

WordPress Visual and Text Editor tabs

Find the paragraph you would like to add a gap of space beneath and add back the paragraph tags (the <p> at the beginning, and </p> and the end). Then add a bottom margin to your paragraph using the style attribute, like so:

<p style="margin-bottom: 100px;">This is a paragraph I want to add a 100 pixel gap after.</p>

If you want to add space above, just use the margin-top property instead. Now if you click back over to the “visual” side of the editor you should be able to see a gap the exact pixel size you entered.

Add Margin with CSS

Wrapping Up

Hopefully this quick tutorial was able to help! If you have any questions feel free to leave them in the comments section below and we’ll do our best to provide a helpful answer.

Subscribe to the Newsletter

Get our latest news, tutorials, guides, tips & deals delivered to your inbox.


  1. Sergio

    Just tried this in 3.7 and it works perfectly. Thanks.

  2. sƃoɹɟqǝʍ (@webfrogs)

    This works great. Thanks for this!

  3. Liviu Plesoianu

    Thank you for this! It is really, really helpful!

  4. Mk

    After years of struggle and cursing wordpress. The ultimate solution! And sooo simple. Thanks a zillion man 🙂

  5. parlopisrael

    It does the trick!!!! thanks man!!!

  6. Elizabeth M

    Thanks so much for this! When nothing else worked, your css tidbit worked perfectly! Yaaaay!

  7. A Walton

    Is there a character to place in uploadeded text ( before uploadinging) to create the equivalent of Shift – Enter?

    • Kyla

      I’m not sure what you mean by uploaded text, but shift-enter does work in the rich text editor to go to the next line with no spacing between lines.

  8. Nyx

    Thanks for this tutorial, AJ! It’s exactly what I needed. : )

  9. Ankit

    thanks for this quick tip!

  10. Mark

    I will confirm this works in WordPress version 5.8

    What would be great is to extend the PHP code snippet to insert this function via an icon into the WordPress page editor toolbar as [br].

    That would make this 100% complete.

  11. Tony

    Thanks! This worked for me 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Learn how your comment data is processed by viewing our privacy policy here.