<div align=""></div>
ブラウザ |
|
---|---|
分類 | |
要素 |
div要素に align=""
を追加すると、内容の水平方向の表示位置を指定できます。
<div align="center">センターに表示します</div>
属性 | 値 | 説明 |
---|---|---|
align="" |
left |
左寄せで表示 |
center |
中央揃えで表示 | |
right |
右寄せで表示 | |
justify |
両端揃えで表示 |
上記の属性は、HTML 4.01では非推奨とされています。(Strict DTDでは使用できません)
justify
の指定について
複数行に渡る長い文章の場合に、各行(最終行を除く)の右端が綺麗に揃うように単語間隔が自動的に調整されます。(英文などの場合に有効のようです)
使用例
left
、center
、right
の指定例
<div align="left">左寄せ</div>
<div align="center">中央揃え</div>
<div align="right">右寄せ</div>
- 表示例
-
左寄せ中央揃え右寄せ
justify
の指定例
<div style="width: 50%; margin-bottom: 20px; border: 1px #808080 solid;">
英文は単語の区切りで改行が ...
</div>
<div align="justify" style="width: 50%; border: 1px #808080 solid;">
英文は単語の区切りで改行が ...
</div>
- 表示例
-
英文は単語の区切りで改行が入るため、行末が綺麗に揃わない場合がありますが、justifyを指定しておくと綺麗に揃えることができます。The align attribute specifies the horizontal text alignment. The justify value adjust the spaces between the words to justify both left and right side.英文は単語の区切りで改行が入るため、行末が綺麗に揃わない場合がありますが、justifyを指定しておくと綺麗に揃えることができます。The align attribute specifies the horizontal text alignment. The justify value adjust the spaces between the words to justify both left and right side.
- ブラウザの幅を動かすと違いが分かりやすいです。