text-justifyプロパティは、text-alignプロパティの値に justify を指定した際の、均等割付の形式を指定する際に使用します。
text-justifyはインラインボックスに適用されるプロパティですが、ブロックコンテナから継承されます。
■値
- auto
- ユーザーエージェントに依存。ユーザーエージェントは、内容テキストの言語や記述方法に適した形式の均等割付を選択する(初期値)
- none
- 均等割付が無効となる
- inter-word
- 単語の区切りの間隔を調整することで均等割付にする。英語や韓国語のように単語をスペースで区切る言語に向いた値
- inter-character
- 文字同士の間隔を調整することで均等割付にする。日本語などの言語に向いた値
※ブラウザによっては inter-character の代わりに distribute と指定しても同様の結果が得られるかもしれません。
これは過去に distributeキーワードが標準仕様として検討されたことがあり、その互換性を確保するためです。
■初期値・適用対象・値の継承
- 初期値
- auto
- 適用対象
- インラインボックス
- 値の継承
- する
■使用例
CSSソースは外部ファイル(sample.css)に記述
p.sample { width:200px; background-color:#99cc00; text-align:justify; }
HTMLソース
<h5>text-justify:auto; を指定</h5> <p class="sample" style="text-justify:auto;"> かえるぴょこぴょこみぴょこぴょこ。 </p> <p class="sample" style="text-justify:auto;"> Three frogs leaping together. They're three pyokopyoko. </p> <h5>text-justify:none; を指定</h5> <p class="sample" style="text-justify:none;"> かえるぴょこぴょこみぴょこぴょこ。 </p> <p class="sample" style="text-justify:none;"> Three frogs leaping together. They're three pyokopyoko. </p> <h5>text-justify:inter-word; を指定</h5> <p class="sample" style="text-justify:inter-word;"> かえるぴょこぴょこみぴょこぴょこ。 </p> <p class="sample" style="text-justify:inter-word;"> Three frogs leaping together. They're three pyokopyoko. </p> <h5>text-justify:inter-character; を指定</h5> <p class="sample" style="text-justify:inter-character;"> かえるぴょこぴょこみぴょこぴょこ。 </p> <p class="sample" style="text-justify:inter-character;"> Three frogs leaping together. They're three pyokopyoko. </p>
ブラウザ上の表示
text-justify:auto; を指定
かえるぴょこぴょこみぴょこぴょこ。
Three frogs leaping together. They’re three pyokopyoko.
text-justify:none; を指定
かえるぴょこぴょこみぴょこぴょこ。
Three frogs leaping together. They’re three pyokopyoko.
text-justifyinter-word; を指定
かえるぴょこぴょこみぴょこぴょこ。
Three frogs leaping together. They’re three pyokopyoko.
text-justify:inter-character; を指定
かえるぴょこぴょこみぴょこぴょこ。
Three frogs leaping together. They’re three pyokopyoko.
■Internet Explorer独自拡張の値
※Internet Explorer限定ですが、以下の値を使用すると期待する結果が得られるかもしれません。
これはtext-justifyプロパティがもともとIEの独自拡張であったことに由来しています。
- distribute
- 単語間隔と文字間隔を調整して均等割付します。
- distribute-all-lines
- 単語間隔と文字間隔を調整して均等割付します。途中の改行や最終行などの文字数が一行に満たない行も均等に割り付けます。
- inter-cluster
- アジアの言語などの単語間隔を持たない言語のテキストを均等割り付けします。
- inter-ideograph
- 日本語・中国語・韓国語など表意文字のテキストの、単語間隔と文字間隔の両方を調整して均等割付します。
- inter-word
- 単語間隔のみを調整して均等割付します。
- kashida
- アラビア文字のテキストの均等割り付けを意図しています。
- newspaper
- 単語間隔と文字間隔を調整して均等割付します。英文などラテンアルファベットに最適な指定方法です。
■使用例(Internet Explorer限定)
CSSソースは外部ファイル(sample.css)に記述
p.sample { width:200px; background-color:#99cc00; text-align:justify; }
HTMLソース
<h5>text-justify:distribute; を指定</h5> <p class="sample" style="text-justify:distribute;"> かえるぴょこぴょこみぴょこぴょこ。 </p> <p class="sample" style="text-justify:distribute;"> Three frogs leaping together. They're three pyokopyoko. </p> <h5>text-justify:distribute-all-lines; を指定</h5> <p class="sample" style="text-justify:distribute-all-lines;"> かえるぴょこぴょこみぴょこぴょこ。 </p> <p class="sample" style="text-justify:distribute-all-lines;"> Three frogs leaping together. They're three pyokopyoko. </p> <h5>text-justify:inter-cluster; を指定</h5> <p class="sample" style="text-justify:inter-cluster;"> かえるぴょこぴょこみぴょこぴょこ。 </p> <p class="sample" style="text-justify:inter-cluster;"> Three frogs leaping together. They're three pyokopyoko. </p> <h5>text-justify:inter-ideograph; を指定</h5> <p class="sample" style="text-justify:inter-ideograph;"> かえるぴょこぴょこみぴょこぴょこ。 </p> <p class="sample" style="text-justify:inter-ideograph;"> Three frogs leaping together. They're three pyokopyoko. </p> <h5>text-justify:kashida; を指定</h5> <p class="sample" style="text-justify:kashida;"> かえるぴょこぴょこみぴょこぴょこ。 </p> <p class="sample" style="text-justify:kashida;"> Three frogs leaping together. They're three pyokopyoko. </p> <h5>text-justify:newspaper; を指定</h5> <p class="sample" style="text-justify:newspaper;"> かえるぴょこぴょこみぴょこぴょこ。 </p> <p class="sample" style="text-justify:newspaper;"> Three frogs leaping together. They're three pyokopyoko. </p>
ブラウザ上の表示
text-justify:distribute; を指定
かえるぴょこぴょこみぴょこぴょこ。
Three frogs leaping together. They’re three pyokopyoko.
text-justify:distribute-all-lines; を指定
かえるぴょこぴょこみぴょこぴょこ。
Three frogs leaping together. They’re three pyokopyoko.
text-justify:inter-cluster; を指定
かえるぴょこぴょこみぴょこぴょこ。
Three frogs leaping together. They’re three pyokopyoko.
text-justify:inter-ideograph; を指定
かえるぴょこぴょこみぴょこぴょこ。
Three frogs leaping together. They’re three pyokopyoko.
text-justify:kashida; を指定
かえるぴょこぴょこみぴょこぴょこ。
Three frogs leaping together. They’re three pyokopyoko.
text-justify:newspaper; を指定
かえるぴょこぴょこみぴょこぴょこ。
Three frogs leaping together. They’re three pyokopyoko.