Social Login

Categories

Get Updates in Your Mailbox

Enter your email address:

Delivered by FeedBurner

Old Archives

Want to check out the earlier archives of the classic WebbyZone blog? Click the button below to go to the old blog.

Old WebbyZone Archives

Tweaking “<br>” Style for WordPress Editor

wp-br-featured

Wordpress has evolved into a complete CMS system and more over the years. But one minor thing that still causes some trouble is the editor that comes bundled with Wordpress installations. While I cannot surely negate the fact that it is a wonderful editor - I have recently come across a small but crucial issue caused by it. It is the use of <br>.

The problem is if you use <br> twice to use it for a hard break it gets converted to <p>. That said, if you have already styled the paragraph tag in your CSS, your hard break will start behaving like one.

So How To Resolve This Issue?

It is only with a little tweak that you can solve this problem, as you cannot style br tags directly from the CSS. For this, we need good old jQuery.

Use the following jQuery code inside the header:

$(document).ready(function() {
    $('br').replaceWith('<span class="br"></span>');
});

The above jQuery code will basically replace all br tags with a span having the class br. Now all we need to do is go to our CSS file and add some style to the br class and we are done. Short, sweet and simple! Hope it helps.

Do Not Forget To Download and Include The jQuery Library

About the author

Written by

Web and technology enthusiast, struggling entrepreneur and hardcore webbie.

2 Responses

  1. I’ve recently started a website, the info you provide on this site has helped me tremendously. Thank you for all of your time & work.

  2. I think this is one of the most significant information for me. And i’m glad reading your article. But want to remark on few general things, The web site style is wonderful, the articles is really excellent : D. Good job, cheers

Comment on this post

You must be logged in to post a comment.

filo kiralama