-ms-word-wrap property (Internet Explorer)

Switch View :
ScriptFree
-ms-word-wrap property

[This documentation is preliminary and is subject to change.]

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

CSS Text Level 3, Section 7.2

Syntax

-ms-word-wrap: normal | break-word

Property values

normal

Default. Content exceeds the boundaries of its container.

break-word

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

CSS information

Applies ToAll elements
Mediavisual
Inherited1
Initial Value

Standards information

Remarks

Windows Internet Explorer 8. The -ms-word-wrap attribute is an extension to CSS, and can be used as a synonym for word-wrap in IE8 Standards mode.

Use this property to enable the browser to break up otherwise unbreakable strings.

This differs from the white-space property, which turns wrapping of the text on and off. The -ms-word-wrap property addresses only whether wrapping is permitted to occur at a place in the word that is not otherwise allowed by the language rules in effect.

This property is read-only for the IHTMLCurrentStyle2 interface.

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.

Examples

The word "blonde" is not wrappable under typical English rules. But, when wordWrap is set to break-word, the word "blonde" can be split onto two lines in any way the browser chooses: such as "b" and "londe", or "blo" and "nde".

The following example shows how to use the break-word value of the -ms-word-wrap property to break one long word onto 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.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/wordWrap.htm


<P STYLE="word-wrap:break-word;width:100%;left:0">
LongWordLongWord...LongWordLongWord</P>

See also

CSSStyleDeclaration
currentStyle
runtimeStyle
style
Reference
line-break
-ms-word-break
white-space

 

 

Build date: 3/14/2012

Community Content

Marc Stober
td element
From what I can tell, to get this style to work on a table cell (td) element, the table my have a style of table-layout: fixed. $0$0 $0 $0This kind of make sense, as it would be contradictory to ask the table to determine its own width based on content (which is the default), and then to ask the text be wrapped to an already-determined width. But, it would be useful to have that officially documented if it is the intent.$0

Mr. Raymond Kenneth Petry
Remark - time consumption - in conjunction with TEXTAREA, XMP

For text-only elements this consumes time, eg. pasting a 1MB-text-file, 1 min./PC-GHz.

A tentative remedy for large MB-text, is to use--
1. a contentEditable HTML-area (for text),
2. an onpaste-event surrogate, and,
3. a dummy-wrapper:

eg:

<CITE>
<DIV id=prepTextarea contentEditable
onpaste='var spot=document.selection.createRange();spot.text=clipboardData.getData("text");return false'
style=PADDING:2;WIDTH:384;HEIGHT:40;BORDER:0;FONT-SIZE:16px;COLOR:white;BACKGROUND-COLOR:maroon;OVERFLOW-Y:scroll;WORD-WRAP:BREAK-WORD;OVERFLOW-X:hidden;CURSOR:text; etc.>
<XMP>pretext before using</XMP>
</DIV>
</CITE>


Here the <CITE> dummy-wrapper tells Microsoft to 'play-IBM' and jumper the delay.

Alternative dummy-wrappers include <LISTING> which is fastest and cleanest-looking (compresses internal margin) but deprecated... etc.

STATUS: TENTATIVE
PROBLEMS: onpaste must wait for clipBoard to fill from source (else it pastes the prior value, as happens on large-MB text).
BENEFITS: zowie-fast: 3 sec. instead of 1 min. on MB-text.