Vlastnost Style fontWeight
Příklad
Nastavte tloušťku písma pro prvek na "900":
document.getElementById("demo").style.fontWeight = "900";
Definice a použití
Vlastnost fontWeight nastavuje nebo vrací, jak tlusté nebo tenké znaky mají být v textu zobrazeny.
Podpora prohlížeče
Property | |||||
---|---|---|---|---|---|
fontWeight | Yes | Yes | Yes | Yes | Yes |
Syntax
Vraťte vlastnost fontWeight:
object.style.fontWeight
Nastavte vlastnost fontWeight:
object.style.fontWeight = "normal|lighter|bold|bolder|value|initial|inherit"
Hodnoty vlastností
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 |
Technické údaje
Výchozí hodnota: | normální |
---|---|
Návratová hodnota: | Řetězec, představující tučnost písma |
Verze CSS | CSS1 |
Další příklady
Příklad
Ukázka možných hodnot:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontWeight = listValue;
Příklad
Vrátí tloušťku písma prvku:
alert(document.getElementById("demo").style.fontWeight);
Související stránky
CSS tutoriál: CSS Font
CSS reference: vlastnost font-weight
HTML DOM reference: vlastnost fontu
❮ Objekt stylu