スタイルfontSizeプロパティ
例
要素のフォントサイズを「x-large」に設定します。
document.getElementById("demo").style.fontSize = "x-large";
定義と使用法
fontSizeプロパティは、テキストのフォントサイズを設定または返します。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
fontSize | Yes | Yes | Yes | Yes | Yes |
構文
fontSizeプロパティを返します。
object.style.fontSize
fontSizeプロパティを設定します。
object.style.fontSize = "value|initial|inherit"
プロパティ値
Value | Description |
---|---|
xx-small x-small small medium large x-large xx-large |
Sets the size of the font to different fixed sizes, from xx-small to xx-large |
smaller | Decreases the font-size by one relative unit |
larger | Increases the font-size by one relative unit |
length | Defines the font-size in length units |
% | Sets the font-size to a % of the parent element's font size |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
技術的な詳細
デフォルト値: | 中くらい |
---|---|
戻り値: | 要素内のテキストのフォントサイズを表す文字列 |
CSSバージョン | CSS1 |
その他の例
例
可能な値のデモンストレーション:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontSize = listValue;
例
要素のフォントサイズを返します。
alert(document.getElementById("demo").style.fontSize);
関連ページ
CSSチュートリアル:CSSフォント
CSSリファレンス:font-sizeプロパティ
HTML DOMリファレンス:フォントプロパティ
❮スタイルオブジェクト