JavaScript EditorBest javascript editor debugger     Ajax website 

Main Page

Previous Page
Next Page

Setting White Space Properties

By default, multiple spaces and returns in an (X)HTML document are either displayed as a single space or ignored outright. If you want the browser to display those extra spaces, use the white-space property.

Figure 10.31. The nowrap value for white-space treats spaces as non-breaking.

To set white space properties:

Type white-space:.

Type pre to have browsers display all the spaces and returns in the original text.

Or type nowrap to treat all spaces as non-breaking.

Or type normal to treat white space as usual (see page 32).

Figure 10.32. The table of contents line won't wrap, even when the browser window is too narrow to display the entire line.


  • The value of pre for the white-space property gets its name from the pre tag, which is an old-fashioned HTML tag that displays text in a monospace font while maintaining all of its spaces and returns. The pre tag, in turn, got its name from the word "pre-formatted". You can find more information about the pre tag on page 73.

  • Note that the pre value for the whitespace property has no effect on an element's font (in contrast with the pre tag, which changes the display to a monospace font).

  • You may use the br tag to manually create line breaks in an element styled with white-space:nowrap. For details about the br tag, consult Creating a Line Break on page 66.

  • IE versions earlier than 6 don't support the pre value for white-space.

Previous Page
Next Page

JavaScript EditorBest javascript editor debugger     Ajax website