Forced line breaks in Wordpress
I’ve been so busy lately that I haven’t realized the many changes in Wordpress 2.3.2. And now they’re playing with version 2.5, but some changes are causing complaints, so I won’t go into that.
Remember how you couldn’t get Wordpress to hold a no-break space even though you typed in the code? Well, there’s still some issues with that and to make it work is trial and error. You can try this: when using the built-in editor, click on the Show/Hide advanced tool icon, then select the Insert Custom Character icon. The first character is the no-break space. That doesn’t always work. You could also go into the code view and add the code which I will do now.
The thing is, putting in the space uses the code tags, and there’s a style called “code” in the CSS for this theme. So, this gives a clue as to how to solve the linebreak issue. If you see a big blank space above, it’s because the “code” element in the CSS for this theme has margins and padding. So just putting in the tags for “code” creates the spacing. If I look in the code for the space above, I don’t see anything but the code tags - there’s no code for the linebreak.
NOTE: If you prefer to work in code, just turn off the wysiwyg editor and use code.
BEST WAY: The best way to force breaks between paragraphs is to use CSS. After all, it’s CSS that is supposed to control the visual style, right? In the p tag, give it a bottom margin of 1em. This will add a bottom margin every time you start a new paragraph. You can play with that and see how much space you like. Then you don’t have to think about adding code or ending up with weird stuff. This certainly makes formatting a blog much nicer. For example, if you visit my Wordpress testing area and view this similar post in different themes, you’ll see different spacing between paragraphs. This isn’t because of code, it’s the styling on the p tag! Wordpress isn’t exactly like a word processor, you have to think a little differently. A space is a space. The size of it can be determined by style, not by whether you use the enter key or shift enter.
Just be careful about the p tag, as you probably have more than one. There’s a p tag style for different areas, like content p, or sidebar p, or post p. So, you can have different spacing in different areas. The menu to the left has different p tag spacing than the post area.
If you want to force double spaces for some reason, then you might have to create a new style for that and apply it to the paragraph. If you want this sort of style control, you’ll have to get a bit familiar with CSS.
In fact, after this post, I’m going to add a bottom margin to my p tag so I don’t have to think about this any more. And there should be spaces between every paragraph. Note: every time you hit the enter key in Wordpress, it creates a new paragraph and automatically puts in the p tag.
Posted in Dubbin'round

June 12th, 2009 at 4:05 pm
Hi, very nice post. I have been wonder’n bout this issue,so thanks for posting