HBCMS更多的中文手册参考:

white-space Attribute | whiteSpace参数属性

DHTML文档教程

Sets or retrieves a value that indicates whether lines are automatically broken inside the object.

What's New for Microsoft® Internet Explorer 6

This property now applies to the currentStyle element. The pre value of this property is now supported.

dhtml语法

HTML { white-space : sWrap }
Scriptingobject.style.whiteSpace(v) [ = sWrap ]

DHTML可能的值

sWrapString that specifies or receives one of the following values.
normalDefault. Lines of text break automatically. Content wraps to the next line if it exceeds the width of the object.
nowrapLine breaks are suppressed. Content does not wrap to the next line.
pre  Line breaks and other whitespace are preserved. This possible value is supported in Internet Explorer 6 and later when the !doctype declaration specifies standards-compliant mode. when the !doctype declaration does not specify standards-compliant mode, you can retrieve this value, but it does not affect rendering—it functions like the normal value.

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 Cascading Style Sheets (CSS) attribute 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

whitespace, such as line breaks, spaces, and tabs, is collapsed by default in html documents. you can use the nonbreaking space entity?span class="clsliteral">( ) to add extra spaces to an object when the whitespace property is set to normal or nowrap. you can add extra line breaks using the br element.

this property affects content you access through the document object model (dom) the same way it affects the way internet explorer displays the content.

Examples

The following example shows how automatic line breaks are suppressed when the user places the mouse pointer over the paragraph. This is caused by toggling the value of the white-space attribute in the onmouseover and onmouseout events of the p element. when the white-space attribute is set to nowrap in the onmouseover event, line breaks are suppressed, and horizontal scrolling is required to view content wider than the element. when the attribute is set to normal in the onmouseout event, lines break automatically, depending on the width of the element.

<HTML>
<HEAD>
<STYLE>
.clsOneLiner  {white-space: nowrap}
.clsAutoBreak {white-space: normal}
</STYLE>
</HEAD>
<BODY>
<P ONMOUSEOVER="this.className='clsOneLiner';"
ONMOUSEOUT="this.className='clsAutoBreak';">
Long lines of text remain unbroken when the value of the whitespace
attribute is set to nowrap. Place your mouse over the text to
suppress automatic line breaks.</P>
</BODY>
</HTML>
This feature requires Microsoft® Internet Explorer 5.5 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

The following example shows how to set and retrieve the value of the whiteSpace property. When the user sets the value of the whiteSpace property of a div element, the value of the property is retrieved in a span element.

<!doctype html public "-//w3c//dtd html 4.0 //en"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<HTML>
<HEAD>
<SCRIPT>
function fnSwitch(){
oDiv.style.whiteSpace = event.srcElement.innerText;
document.all.oSpan.innerText = oDiv.currentStyle.whiteSpace;
}
</SCRIPT>
</HEAD>
<BODY>
<BODY>
<H1>direction Property Sample</H1>
<H2>direction:
<SPAN id="oSpan" style="color:red"></SPAN></H2>
<P>[ <A href="#" onclick=fnswitch()>normal</a> | <a href="#"
onclick=fnSwitch()>nowrap</A> | <A href="#" onclick=fnSwitch()>pre</A> ]</P>
<DIV id="oDiv" style="background:#e4e4e4; padding:10px;">
In   the   source,   this   sentence   has   three   spaces   between   each   word.
This sentence
takes up three
lines in the source.
</DIV>
</BODY>
</HTML>
This feature requires Microsoft® Internet Explorer 6 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

是否符合公共标准

This property is defined in Cascading Style Sheets (CSS), Level 1 (CSS1) Non-Microsoft link.

Applies To

ACRONYM, ADDRESS, BASEFONT, BLOCKQUOTE, BDO, BIG, BODY, CENTER, CITE, CODE, currentStyle, CUSTOM, DD, DIV, DIR, DL, DT, EM, FIELDSET, FORM, FONT, hn, HR, ISINDEX, I, INS, KBD, LABEL, LEGEND, LI, LISTING, MENU, OL, P, Q, PLAINTEXT, PRE, S, SMALL, SPAN, STRIKE, STRONG, style, SUB, SUP, TT, U, UL, XMP

更多语法参考

css enhancements in internet explorer 6, pre, wordWrap