word-wrap Attribute | wordWrap Property

Sets or retrieves whether to break words when the content exceeds the boundaries of its container.

Syntax

HTML

{ word-wrap : sWrap }

Scripting

object.style.wordWrap [ = sWrap ]

Possible Values

sWrap

String that specifies or receives one of the following values.

normal

Default. Content exceeds the boundaries of its container.

break-word

Content wraps to next line, and a word-break occurs when necessary.

The property is read/write for all objects except the following, for which it is read-only: currentStyle . The property has a default value of normal . The Microsoft Cascading Style Sheets (CSS) extension is inherited.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties .

Remarks

This property is read-only for the currentStyle object.

This property applies to elements that have layout. An element has layout when it is absolutely positioned, is a block element, or is an inline element with a specified height or width.

Example

The following example shows how to use the break-word value of the wordWrap property to break one long word into multiple words on multiple lines. This value avoids horizontal scrolling and can be useful for printing. The p element in this example has layout, because its width is set.