Re: Wordwrap in <PRE>-formatted text

On Wed, 17 Mar 1999, Arne Stenstadvold, ABTV wrote:

> Anybody out there who can help me with information on how to get
> wordwrapping in preformatted text? I use the <PRE> command, but need
> the text to wrap according to the size of the browser window.

Are you sure you are using the right element? PRE indicates that the
formatting (which includes wrapping) has already been done and that
therefore there is no need to format it again (eg, by wrapping it).


Wrapping of the PRE element is a stylistic issue, anyway, and as such
is in the realm of CSS.

The correct CSS to use to make spaces collapse and lines wrap in PREs
is:
 
   PRE { white-space: normal; }

You cannot currently make spaces remain uncollapsed and let lines
wrap, but I have suggested in www-style that the 'nocollapse' keyword
be allowed, which would ignore line ends in the markup, rewrapping as
necessary, but would preserve linear whitespace. It would be used as
follows:

   PRE { white-space: nocollapse; }

This would work analogously to the nowrap keyword, which preserves
line ends but collapses whitespace.

Unfortunately, 'white-space' is not supported in IE4.

[Follow-ups should go to www-style]
-- 
Ian Hickson 
U+2642 U+2651
U+262E U+2603 U+263A

Received on Wednesday, 17 March 1999 08:31:31 UTC