Skip to Content
Web Design in a Nutshell, 3rd Edition
book

Web Design in a Nutshell, 3rd Edition

by Jennifer Robbins
February 2006
Intermediate to advanced
826 pages
63h 42m
English
O'Reilly Media, Inc.
Content preview from Web Design in a Nutshell, 3rd Edition

The normal value treats text normally, with consecutive spaces collapsing to one. The pre value displays multiple characters, like the pre element in (X)HTML, except that it has no effect on the font of the element (browsers tend to display pre elements in the monospace font).

Figure 18-21 shows a simple use of the white-space property as specified in this example style and markup.

    p.haiku {white-space: pre; }

    <p class="haiku">
        Love's pure silver flame
            gives each innermost spirit
      invisible warmth.
    </p>
The white-space property

Figure 18-21. The white-space property

nowrap prevents the text element from wrapping unless designated by a <br />. Without a <br />, the text may extend beyond the browser window, requiring horizontal scrolling.

CSS 2.1 introduced two new values for white-space. The pre-wrap value preserves multiple character spaces but allows long lines of text to wrap. Line breaks in the source are also honored. The pre-line value makes multiple character spaces collapse to one, but it preserves new lines in the source. As of this writing, no browser supports the pre-line and pre-wrap values for white-space.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Responsive Web Design with HTML5 and CSS3

Beginning Responsive Web Design with HTML5 and CSS3

Jonathan Fielding

Publisher Resources

ISBN: 0596009879Errata Page