Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Style whiteSpace property

Style whiteSpace property

Style Object Reference The Style object


Definition and Usage

The whiteSpace property sets or returns how to handle tabs, line breaks and spaces in text.

Syntax

Set the whiteSpace property:

Object.style.whiteSpace="normal|nowrap|pre|inherit"

Return the whiteSpace property:

Object.style.whiteSpace

Value Description
normal Default. Whitespace and line breaks are ignored automatically.
nowrap Whitespace is ignored, but line breaks are not allowed.
pre Line breaks and other whitespace are preserved.
inherit The value of the whiteSpace property is inherited from the parent element.

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the whiteSpace property.

**Note:** IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".


Example

Example

Preserve line breaks and whitespace in text:

Runoob Tutorial(runoob.com)

This is some text, this is some text. This is

some text, this is some text, this is some text.


Try it »


Style Object Reference The Style object