View Full Version : Using Line Break in WP
davemcnally
09-24-2007, 06:39 PM
I am writing out a portfolio page at the moment. Each time I insert "<br />" into the code, Wordpress is ignoring it. I checked the source code upon publishing the page and it isn't even in there!
Any ideas why this wouldn't be working? If it makes a difference, I have the WYSIWYG editor disabled.
Thanks :)
ses5909
09-24-2007, 07:05 PM
I haven't had any issues using <br />
What happens when you use <p> </p> tags??
BPartch
09-24-2007, 07:14 PM
hello
When using the WP text area, with no WYSIWYG you can create paragraphs by creating a space between lines like so:
This is a paragraph
This is another paragraph.
To create a line break you can just move it to teh next line:
This is a paragraph
that has a line break in it.
You do not have to actually enter the <p> or the <br /> though there should be no issue with doing so.
<p>This is a paragraph</p>
<p>This is another paragraph.</p>
or
<p>This is a paragraph<br />
that has a line break in it.</p>
Hope it helps. :)
davemcnally
09-24-2007, 07:32 PM
I am trying to use multiple line breaks to create a few lines of space between elements on a page. Each time I enter a line break though, WP is converting it into a <p> element and therefore I only get the effect of one linebreak
The <p> element works fine but only goes to next line, it doesn't skip so many.
*edit - decided to just use a DIV instead and give it a margin
Michael Martin
09-24-2007, 07:47 PM
Try:
<p style="margin-bottom:5em;"> </p>
(Change the value to whatever number of lines you want to skip, minus one). WordPress will still delete the </p> most likely, but it should leave the start of it.
SarahG
09-24-2007, 08:59 PM
WordPress will tend to try and correct what you've entered. In this case it thinks what you've added is wrong.
If you want to get around it you can add the Mark Down plugin that allows you to add your own code and disables WordPress from interfering.
jMcQuarrie
09-24-2007, 10:02 PM
Could you post a snippet of the code that you're getting? My first guess would be that you may be able to add some padding / margin to the <p> elements via a style sheet, without the need for the <div> but without more detail I could be talking rubbish.
davemcnally
09-24-2007, 10:48 PM
Could you post a snippet of the code that you're getting? My first guess would be that you may be able to add some padding / margin to the <p> elements via a style sheet, without the need for the <div> but without more detail I could be talking rubbish.
Right,
What I was initially trying to do was add two line breaks in between entries on a page. I was trying to do this as follows:
.....
end of one section</p>
<br /><br /><p>start of new section
.....
But, Wordpress was simply taking out my line breaks, leaving me with just the <p> tags in there and with only one single line break.
I used a DIV in the end to get around it, it also gave me a bit more control over styling other elements on the page :)
kimberlybarryd
09-24-2007, 10:51 PM
Shift + enter will give a line beak.
davemcnally
09-24-2007, 11:22 PM
Shift + enter will give a line beak.
I'm not sure exactly what you mean. Are you talking about when you are inside WP's editor?
I wasn't having a problem getting a line break in total, I always had the option of using a DIV, the question was trying figure out why the <br /> tag was not working.
kimberlybarryd
09-25-2007, 12:04 AM
Yes in th WP's editor. The break tags Don't show up on my either, But shift + enter will leave the proper spacing.
goldfries
09-25-2007, 12:39 AM
I've not used break tags with WP. i just press more ENTER key. :)
didn't like the WYSIWYG editor though, I didn't enable it once. and once I saved my document, WTF all my DIVs turned into P !!!
davemcnally
09-25-2007, 12:48 AM
I tried hitting enter a couple more times too but it just ignored them...
In the end, it worked out better for me that the line breaks didn't work as it led me to using a div and realising I had something else that could be styled differently!
Thanks for the advice though ;)
jMcQuarrie
09-25-2007, 07:21 AM
In that case sounds like a <div> is a good call. Looking forward to seeing the results.
goldfries
09-25-2007, 07:58 AM
i use DIV often in my post, customized it in CSS of course.
the rest of the content, it's WP that adds, like the P tags for example.
I did a validator check on my PC BUYING GUIDE and wow, it was riddled with errors.
After a bit of checking, I realize it wasn't my code issue but rather it was WP being a little lack of intelligence at some point, like for example having some tags too close to a word or something actually resulted in some un-closed tags and so on so forth.
I fixed the problems by having a bunch of "ENTER" on the post / page content and that's it.
mccormicky
09-25-2007, 09:01 AM
The WP editor is definitely bossy. It doesn't like div tags at all. It deletes them or turns them into p. Often I break my pages because one last p wasn't inserted.The editor will delete any simple <p></p> So use p class="blah"></p> and then write the style for it as if it was a div class . You can use p id,too. Doesn't matter. Line height also will help.
oh and use the code mode in the editor! never the visual mode.
SarahG
09-25-2007, 09:36 AM
Having line break tags between paragraphs is invalid and so wordpress is simply cleaning up incorrect code, which is a good thing.
You shouldn't use line break tags for extra spacing, adding in CSS of some sort to add in the extra gap is a much better idea, which is what has been done in this situation.
It's rare (I'm not saying never here) you'll need a div in a blog post. Too many people throw in a div when styling on the paragraph or list would work just as well.
However, as I mentioned earlier, if you want to break away from standard formatting (paragraphs, lists etc) then you need a plugin such as Mark Down to allow you to add in code without it being messed with by WordPress.
goldfries
09-26-2007, 01:55 AM
I only use DIVS on stuff like my customized image headers (yes, the one where i put ratings) and also the thumbnail image holders.
that's it. the text are all up to WP to P it for me.
mccormicky
09-26-2007, 08:35 AM
Pressing enter in the editor's 'visual' mode won't make a line break. But it will in 'code' mode.At least it does for me.
I agree with the no div thing needed in posts but pages are another thing and I think there they are fine to use. I hate how the editor wraps everything(text and images) in a p tag and to get around my padding and margins(or lack thereof) for p being applied to everything I wrap my stuff in my own classes.
But it's a pain to do it every time you write something. There's a plugin for that, makes templates available to choose from in the admin write panel... I forget it's name.
SarahG
09-26-2007, 09:24 AM
There's a plugin for that, makes templates available to choose from in the admin write panel... I forget it's name.
The plugin to make your code from being altered is called Mark Down. You can then select whether you use it or not per post/page if you want.
Making templates available to choose from in the write panel doesn't need a plugin (unless I've misread what you mean). When you create page templates and give them all unique template names they will appear automatically as an option in the write page panel.
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.