Line Break Not Working in WordPress

By on January 29, 2013

Recently i switched my wordpress theme and faced some problems with line breaks.

I searched about it over the wordpress forum and discovered many other related problems as well.

So in this post i will cover all those problems in detail.

#1 – CSS Problem

Check the image below. The first case is where everything is alright and Line breaks are working.

In the second case the line breaks are failing. You can see that in second case there is no space between two html paragraphs (<p> and </p> tags).

line-breaks-in-wordpress-posts

This is because of your theme style. All you need to do is add margin-bottom: 15px; to your post paragraph. If you have basic knowledge of CSS then all you need to do is add bottom 15px margin to the p tag of post-area class or entry class. Since most themes use entry class for the main content.

Now for those who don’t know CSS – Follow the instructions given below.

  • 1) Goto any of your wordpress post.
  • 2) Select some text from the post.

inspect-element-of-single-p

  • 3) Right click and click on inspect element.
  • 4) A pop up will appear at the bottom of your browser as shown below.

entry-p-linebreak

  • 5) As you can see my <p> tag is inside the division having class entry.
  • 6) Also the p tag has margin-top: 0px and margin-bottom: 15px
  • 7) But if you are facing a line break problem then you wont see margin-bottom: 15px
  • 8) If that’s the case then you need to edit style.css of your theme.
  • 9) Goto Admin dashboard > Click Apperance > Click Editor. Style.css file shows up.
  • 10) Add the following code at the very end of the file:

.entry p {

margin-bottom: 15px;

}

Note that i am using .entry because my <p> tag is inside division with a class named entry. Most themes use the same class, But if your theme is using a different one then replace .entry with the respective class of your theme. If you can’t find it, I can help you find it, just leave a comment on this post.

  • 11) Then save the file.
  • 12) Goto your post, Now the changes must take effect.

#2 – Autop() Problem

If all your text is coming in one single line even though you have added line breaks to your post then this is a Autop() related problem. Autop() is a function in wordpress which auto formats paragraphs. This is handy for those who don’t want to manually code every post.

All your text is displayed in one single line and the line breaks are ignored because autop() is turned off. And since its turned off automatic formatting of paragraphs is disabled and you will have to manually edit and add line breaks using <br/> tags.

Autop() is by default enabled in WordPress. If its off for your particular site then this must be due to a plugin or theme issue. Check if autop() is turned off in your theme options or in any plugin options. And if it is turned off then turn it on to fix this problem.

autop-disabledIf you want to know how to disable autop, Check out this post by David Walsh. And if you have any questions, feel free to comment below. I will try and help you out as soon as possible. Thanks for reading.

About Omkar Bhagat

Omkar is the owner of Codefap.com. He writes blogs, makes video tutorials and love to learn new things about computers and programming.
Subscribe To Blog Feed
  • Bava

    Thanks bro! I had problem with post blockquotes. I was tired of searching the solution in wordpress and other forums. This is the exact solution I was looking for. Great.

    • http://codefap.com/ Omkar Bhagat

      I’m glad it worked for you. :-)
      Thanks for leaving a comment.