スタイルfontWeightプロパティ
例
要素のフォントの太さを「900」に設定します。
document.getElementById("demo").style.fontWeight = "900";
定義と使用法
fontWeightプロパティは、テキスト内の太い文字または細い文字を表示する方法を設定または返します。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
fontWeight | Yes | Yes | Yes | Yes | Yes |
構文
fontWeightプロパティを返します。
object.style.fontWeight
fontWeightプロパティを設定します。
object.style.fontWeight = "normal|lighter|bold|bolder|value|initial|inherit"
プロパティ値
Value | Description |
---|---|
normal | Font is normal. This is default |
lighter | Font is lighter |
bold | Font is bold |
bolder | Font is bolder |
100 200 300 400 500 600 700 800 900 |
Defines from light to bold characters. 400 is the same as normal, and 700 is the same as bold |
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.fontWeight = listValue;
例
要素のフォントの太さを返します。
alert(document.getElementById("demo").style.fontWeight);
関連ページ
CSSチュートリアル:CSSフォント
CSSリファレンス:font-weightプロパティ
HTML DOMリファレンス:フォントプロパティ
❮スタイルオブジェクト