1. Home
  2. HTMLタグ
  3. ページ全般タグ
  4. 範囲指定+表示位置の指定

範囲指定+表示位置の指定


<div align=""></div>

ブラウザ
IE
Fx
Sf
Cr
O
分類
ブロックレベル要素
非推奨属性
要素
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: 40%; margin-bottom: 20px; border: 1px #808080 solid;">
英文は単語の区切りで改行が ...
</div>

<div align="justify" style="width: 40%; 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.

ページ全般タグ

ページの先頭へ


inserted by FC2 system