Styl Velikost písma Vlastnost
Příklad
Nastavte velikost písma prvku na "x-large":
document.getElementById("demo").style.fontSize = "x-large";
Definice a použití
Vlastnost fontSize nastavuje nebo vrací velikost písma textu.
Podpora prohlížeče
Property | |||||
---|---|---|---|---|---|
fontSize | Yes | Yes | Yes | Yes | Yes |
Syntax
Vraťte vlastnost fontSize:
object.style.fontSize
Nastavte vlastnost fontSize:
object.style.fontSize = "value|initial|inherit"
Hodnoty vlastností
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 |
Technické údaje
Výchozí hodnota: | střední |
---|---|
Návratová hodnota: | Řetězec představující velikost písma textu v prvku |
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.fontSize = listValue;
Příklad
Vrátí velikost písma prvku:
alert(document.getElementById("demo").style.fontSize);
Související stránky
CSS tutoriál: CSS Font
CSS reference: vlastnost font-size
HTML DOM reference: vlastnost fontu
❮ Objekt stylu