CSStext -alignプロパティ
例
さまざまな<div>要素のテキスト配置を設定します。
div.a {
text-align: center;
}
div.b {
text-align: left;
}
div.c {
text-align: right;
}
div.c {
text-align:
justify;
}
以下の「自分で試してみてください」の例をもっと見てください。
定義と使用法
このtext-align
プロパティは、要素内のテキストの水平方向の配置を指定します。
デフォルト値: | 方向がltrの場合は左、方向がrtlの場合は右 |
---|---|
遺伝性の: | はい |
アニメート可能: | 番号。アニメート可能について読む |
バージョン: | CSS1 |
JavaScript構文: | object .style.textAlign = "right" |
ブラウザのサポート
表の数字は、プロパティを完全にサポートする最初のブラウザバージョンを示しています。
Property | |||||
---|---|---|---|---|---|
text-align | 1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
CSS構文
text-align: left|right|center|justify|initial|inherit;
プロパティ値
Value | Description | Play it |
---|---|---|
left | Aligns the text to the left | |
right | Aligns the text to the right | |
center | Centers the text | |
justify | Stretches the lines so that each line has equal width (like in newspapers and magazines) | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
その他の例
例
別のテキスト整列の例:
h1 {
text-align: center;
}
p.date {
text-align: right;
}
p.main {
text-align: justify;
}
関連ページ
CSSチュートリアル:CSSテキスト
HTML DOMリファレンス:textAlignプロパティ