W3C home > Mailing lists > Public > www-html@w3.org > March 1999

Re: Wordwrap in <PRE>-formatted text

From: Ian Hickson <py8ieh@bath.ac.uk>
Date: Wed, 17 Mar 1999 13:31:24 +0000 (BST)
To: "Arne Stenstadvold, ABTV" <arne@abtv.no>
cc: www-html@w3.org
Message-ID: <Pine.GSO.4.04.9903171324290.6243-100000@midge.bath.ac.uk>
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
   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

   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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:05:50 UTC