Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

CHAPTER 6: Manipulating the Display of T... > CONTROLLING HOW WHITE SPACE IS HANDL...

CONTROLLING HOW WHITE SPACE IS HANDLED

The white-space property allows you to control text formatting in the source code of the web document. The following table outlines the keyword values of the white-space property as of CSS 2.

PROPERTY VALUE
white-space normal | pre | nowrap
Initial value: normal

The white-space property is mainly used with the pre keyword value, and it used to output content exactly as it appears in your markup.

The following code snippet is an example of the white-space: pre; declaration applied to a <code> element.

image

<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN”
    “http://www.w3.org/TR/html4/strict.dtd”>
<html lang=“en”>
<head>
    <meta http-equiv=“Content-Type” content=“text/html; charset=utf-8”>
    <title>FIGURE 6-15</title>
    <style type=“text/css”>
        code {
             white-space: pre;
        }
    </style>
</head>
<body>

<code>
&lt;script type=“text/javascript”&gt;
    document.documentElement.className = ‘js’;
&lt;/script&gt;
</code>

</body>
</html>

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial