word-breakプロパティは、W3Cで審議中の仕様をInternet Explorerが独自に採用したもので、
表示範囲に合わせて改行するか、単語の切れ目で改行するかなど、文の改行の仕方について指定する際に使用します。
単語の途中で改行するかどうかを指定するword-wrapプロパティとの使い分けについてですが、
word-wrapプロパティは、文の改行というより、
長い英単語を途中で改行させたくない場合に使用するもののようです。また、日本語の単語に対しては無効なようです。
word-breakプロパティは、CSS3で標準採用されるかもしれません。
■値
- normal
- 英語等は単語の途中では改行せず、単語の切れ目で改行されます。日本語・中国語・韓国語等は表示範囲に合わせて改行されます。このため単語の途中で改行されることもあります。
- break-all
- 言語に関係なく表示範囲に合わせて改行されます。このため単語の途中で改行されることもあります。
- keep-all
- 言語に関係なく単語の途中では改行せず、単語の切れ目で改行されます。
■使用例
スタイルシート部分は外部ファイル(sample.css)に記述。
p.sample1 {width:150px; background-color:#99cc00; word-break: normal;}
p.sample2 {width:150px; background-color:#99cc00; word-break: break-all;}
p.sample3 {width:150px; background-color:#99cc00; word-break: keep-all;}
HTMLソース
<html>
<head>
<link rel=”stylesheet” href=”sample.css”
type=”text/css”>
</head>
<body>
<p class=”sample1″>
英語等は単語の途中では改行せず、単語の切れ目で改行されます。日本語・中国語・韓国語等は表示範囲に合わせて改行されます。このため単語の途中で改行されることもあります。<br>
Default. Allows line breaking within words.
</p>
<p class=”sample2″>
言語に関係なく表示範囲に合わせて改行されます。このため単語の途中で改行されることもあります。<br>
Behaves the same as normal for Asian text, yet allows the line to break arbitrarily for non-Asian text. This value is suited to Asian text that contains some excerpts of non-Asian text.
</p>
<p class=”sample3″>
言語に関係なく単語の途中では改行せず、単語の切れ目で改行されます。<br>
Does not allow word breaking for Chinese, Japanese, and Korean. Functions the same way as normal for all non-Asian languages. This value is optimized for text that includes small amounts of Chinese, Japanese, or Korean.
</p>
</body>
</html>
ブラウザ上の表示
英語等は単語の途中では改行せず、単語の切れ目で改行されます。日本語・中国語・韓国語等は表示範囲に合わせて改行されます。このため単語の途中で改行されることもあります。
Default. Allows line breaking within words.
言語に関係なく表示範囲に合わせて改行されます。このため単語の途中で改行されることもあります。
Behaves the same as normal for Asian text, yet allows the line to break arbitrarily for non-Asian text. This value is suited to Asian text that contains some excerpts of non-Asian text.
言語に関係なく単語の途中では改行せず、単語の切れ目で改行されます。
Does not allow word breaking for Chinese, Japanese, and Korean. Functions the same way as normal for all non-Asian languages. This value is optimized for text that includes small amounts of Chinese, Japanese, or Korean.
■関連項目
text-justify …… 均等割付の形式を指定する(IEが独自に採用)
vertical-align …… 縦方向の揃え位置を指定する
text-decoration …… テキストの下線・上線・打ち消し線・点滅を指定する
text-underline-position・・下線の表示位置を指定する(IE独自の仕様)
text-indent …… 一行目のインデント幅を指定する
text-transform …… テキストの大文字表示・小文字表示を指定する
white-space …… ソース中のスペース・タブ・改行の表示の仕方を指定する
letter-spacing …… 文字の間隔を指定する
word-spacing …… 単語の間隔を指定する
text-autospace …… アルファベット等との間隔を指定する(IEが独自に採用)
line-break …… 禁則処理のしかたを指定する(IEが独自に採用)
word-break …… 文の改行の仕方について指定する(IEが独自に採用)
word-wrap …… 単語の途中で改行するかどうかを指定する(IE独自の仕様)
text-shadow …… テキストに影をつける