CSS - white-space


Description:

The white-space property is used to alter the user agent's handling of whitespace in an element.

Possible Values:

  • normal: Any sequence of whitespaces within the element is converted to a single space.
  • pre: All whitespace in the element is honored, including multiple spaces and carriage returns.
  • nowrap: Any sequence of whitespaces within the element is converted to a single space, but word wrapping is disabled.

Applies to:

All the Block level elements

DOM Syntax:

object.style.whiteSpace="pre";

Example:

Following is the example which demonstrates how white space inside an element is handled.

<p style="white-space:pre;">This text has a line break
and the white-space pre setting tells the browser to honor it
just like the HTML pre tag.</p>

     

This will produce following result:

This text has a line break and the white-space pre setting tells the browser to honor it just like the HTML pre tag.





Spacer Bottom Left Corner ImageBottom Right Corner Image
Valid XHTML 1.0 Strict  Valid CSS! Check the accessibility of this site according to U.S. Section 508