...

View Full Version : pre tag ignores width attribute



me2
12-20-2007, 09:44 AM
when i use the pre tag on text it seems that it continues on in a line if it doesnt have \n is there a way to wrap the text so it doesnt continue on in a line forever??

Excavator
12-20-2007, 09:56 AM
That's the beauty of the pre tag - it follows the previous formatting.
If you want it to break, put it in <p> tags.

me2
12-21-2007, 01:28 AM
<p class="eventinfo"><pre>REally long one lined text line does not seem to work as it does not wrap still</pre></p>

Is that right??

Excavator
12-23-2007, 09:25 PM
No.
The pre tag is for quoting pre-formatted text. Like a paragraph straight from a Word document when you would like to keep the same line breaks and indentation.
<p></p> is paragraph tags

For your sentence to break it should be <p>REally long one lined text line does not seem to work as it does not wrap still</p> . That will break if the containing div it's in is too narrow to fit it on one line.

Of course, some will say since that is only one sentence it should not be enclosed in paragraph tags.

Arbitrator
12-24-2007, 12:30 PM
when i use the pre tag on text it seems that it continues on in a line if it doesnt have \n is there a way to wrap the text so it doesnt continue on in a line forever??It sounds like you want the functionality of one of the CSS2.1 white-space: pre-wrap or white-space: pre-line [1] declarations; you’d apply either to the pre element to alter its line‐breaking behavior. Unfortunately, neither appear to be well‐supported. [2]

As an alternative to trying to control line‐wrapping, you might use the overflow property to specify what should happen to excess content. For example, you could provide a scrollbar with the overflow: auto or overflow: scroll declarations.

You might want to make it more clear what effect you’re trying to achieve though. Right now, I can’t tell if either of the above are really solutions to your issue because I’m not sure what the issue actually is; if I took your question literally, the answer might simply be “don’t use a pre element” (as Excavator has already proposed).


No.
The pre tag is for quoting pre-formatted text. Like a paragraph straight from a Word document when you would like to keep the same line breaks and indentation.If you were copying a real paragraph (as opposed to a Word paragraph), you would probably want to use both elements (pre and p). Better examples (from a semantic standpoint), might be use of a pre element for the preservation of line‐breaks in poetry or code.


Of course, some will say since that is only one sentence it should not be enclosed in paragraph tags.I’d say that a one sentence paragraph is fine; it’s grammatically correct English anyway. The problem is when people stick non‐sentence content in the element and treat it as if it were a Microsoft Word paragraph (which happens to simply be a line‐break).

Of course, one might argue that “REally long one lined text line does not seem to work as it does not wrap still” isn’t actually a sentence since it contains several grammatical errors.


http://www.w3.org/TR/2007/CR-CSS21-20070719/text.html#propdef-white-space
http://www.webdevout.net/browser-support-css#support-css2propsbasic-whitespace



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum