View Full Version : controling <pre> width
I have text that is formated with <pre> going in to a <div> which has its width constrained to 80%. If I want the text not to bust through the <div> and streem endlessly right, what should I do?
10-03-2006, 11:21 PM
You could set overflow:hidden or overflow:scroll for the pre tag. The first will hide what wont fit while the second will add a scrollbar to the pre tag when it is needed.
10-03-2006, 11:32 PM
Have you tried giving the <pre> a width (possibly of 80%) too?
the thing is, that I want the text to form a column, as one might do by placing it inside a div.
I tryed the width on the pre tag itsef already, didnt do anything.
Any other ideas?
10-04-2006, 01:41 AM
I'm guessing that you want new-line and white-space formatting to be preserved but for wrapping to also occur? You would use white-space: pre-wrap for that. Support for it is pretty poor though.
Web Browser CSS Support (http://www.webdevout.net/browser_support_css.php?IE6=on&IE7=on&FX1_5=on&FX2=on&OP9=on&KN3_5=on&SF2=on&uas=CUSTOM#css2propsbasic)
White-Space and Generated Content (http://cheeaun.phoenity.com/weblog/2005/06/whitespace-and-generated-content.html)
Ahh it worked!
font-family:Georgia, "Times New Roman", Times, serif;
white-space: pre; /* CSS2 */
white-space: -moz-pre-wrap; /* Mozilla */
white-space: -hp-pre-wrap; /* HP printers */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: pre-wrap; /* CSS 2.1 */
white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
word-wrap: break-word; /* IE */
that setup gleened off one of your resources did the trick.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.