Page 1 of 1

CSS line breaks

Posted: Mon Dec 08, 2008 10:39 pm
by JellyFish
Hello all, I was curious to know if there is a way to NOT ignore line breaks in an element. As you all know HTML by default ignores line breaks(\n characters), but is there a way through CSS to specify that the element WILL break on the newline characters? For example:

HTML:

Code: Select all

 
<p class="prelines">
This text preserves newline characters and nothing else like 
    tabs or more then one   space characters.
</p>
 
CSS:

Code: Select all

 
.preline {
some-rule-that-preserves-newline-characters: value;
}
 
RESULT:
This text preserves newline characters and nothing else like
tabs or more then one space characters.
What I'm looking for is the some-rule-that-preserves-newline-characters rule. I know I could use the white-space property but I believe this preserves tabs and multiple space characters as well(which is not what I want).

Thanks for reading. I hope there's such a CSS property.

Re: CSS line breaks

Posted: Tue Dec 09, 2008 9:50 am
by pickle
You can use white-space:pre-line. That is, unless you plan on having your site usable by IE. :roll:

http://www.htmldog.com/reference/csspro ... ite-space/