WordPress line break – 1 line solution without plugin
While working with WordPress in Admin Panel, you may have noticed that when you Update/Save the post once you are done entering the Post, WordPress automatically strips out extra line break / paragraph break otherwise commonly known as “WordPress line break problem“.
How to fix line break problem in WordPress
I personally came across this problem. In this post, I am going to give you a 1 line solution to solve this problem, all without using any plugin!
Let me illustrate the exact problem by means of the following image:
As indicated by the red arrow, there is no spacing between the paragraphs even though I have manually forced multiple line breaks. I searched Google to see if there is any solution for this. I did come across TinyMCE plugin that forces WordPress to retain the breaks as you enter them. But then I thought. Really? I need to install a whole plugin just to solve this tiny problem? I don’t think so. I thought to myself. Then I examined the source code of the page to see how WordPress was treating the line breaks and paragraphs and have come up with a 1 line solution for this, without having to install a plugin. This means that you can implement this solution in your blog right away, without installing any plugins. Ready for the solution? Here it is:
In your theme that you are using for the WordPress, add the following style in the style.css style-sheet:
Alternately, you may copy the following code directly into the style-sheet:
p {
margin-bottom: 20px !important;
}What this essentially does is adds a margin to every paragraph that WordPress adds/formats. Using !important forces the browsers to obey this rule and apply this rule by overriding any other rules.
Here’s how it looks like after applying the solution:
As you can see, the spacing between the paragraphs appear making it very neat and tidy. Hope this solution helps out the needy. If you have any questions, please leave a comment below.
Notes:
1. There’s one thing you need to remember. If you enter multiple line breaks, say for example, 5 line breaks between 2 paragraphs and Update the post, if you view the post, you will see all these multiple paragraphs intact i.e you will see 5 line breaks. But when you enter some additional text in the post and Update it again, then WordPress will automatically remove all the extra line breaks and will retain only 1 line/paragraph break. So ideally speaking, there would not be any need for anyone to have 5 line breaks between 2 paragraphs. The maximum number of line/paragraph breaks between any two paragraphs, ideally should not exceed more than one for readability purposes. Using the above solution achieves this purpose.
2. If you want, you can adjust the margin-bottom value to any other value other than 20px, as you see fit.
That’s it!
Do you have any suggestions to fix line break problem in WordPress? Feel free to suggest by commenting below.