Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
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.
<!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>
<script type=“text/javascript”>
document.documentElement.className = ‘js’;
</script>
</code>
</body>
</html>