word-break

word-break 属性规定定非CJK脚本的断行规则。

 

语法

word-break: normal|break-all|keep-all;

描述
normal使用浏览器默认的换行规则。
break-all允许在单词内换行。
keep-all只能在半角空格或连字符处换行。

例子

HTML

<p class="test1"> This paragraph contains some text. This line will-break-at-hyphenates.</p>
<p class="test2"> This paragraph contains some text: The lines will break at any character.</p>

<p><b>注意:</b>  word-break 属性不兼容 Opera.</p>

CSS

p.test1
{
	width:9em; 
	border:1px solid #000000;
	word-break:keep-all;
}

p.test2
{
	width:9em; 
	border:1px solid #000000;
	word-break:break-all;
}

执行结果

This paragraph contains some text. This line will-break-at-hyphenates.

This paragraph contains some text: The lines will break at any character.

注意: word-break 属性不兼容 Opera.

参考

相关链接

外部链接