Style fontSize attribute
- Forrige side fontFamily
- Næste side fontStyle
- Gå tilbage til forrige niveau HTML DOM Style Object
Definition and usage
fontSize
Set or return the font size of the text.
See also:
CSS Tutorial:CSS skrift
CSS Reference Manual:font-size attribute
HTML DOM Reference Manual:font attribute
Instance
Example 1
Set the font size of the <p> element to "xx-large":
document.getElementById("myP").style.fontSize = "xx-large";
Example 2
Demonstration of possible values:
var listValue = selectTag.options[selectTag.selectedIndex].text; document.getElementById("myP").style.fontSize = listValue;
Example 3
Return the font size of the <p> element:
alert(document.getElementById("myP").style.fontSize);
Syntax
Return fontSize property:
object.style.fontSize
Set fontSize property:
object.style.fontSize = "value|initial|inherit"
Attribute value
Value | Description |
---|---|
|
Set the font size to a different fixed size, from xx-small to xx-large. |
smaller | Decrease the font size by a relative unit. |
larger | Increase the font size by a relative unit. |
length | Define the font size using length units. |
% | Set the font size to a percentage of the parent element's font size. |
initial | Set this property to its default value. See initial. |
inherit | Inherit this property from its parent element. See inherit. |
Technical details
Default value: | medium |
---|---|
Return value: | String that represents the font size of the element's text. |
CSS version: | CSS1 |
Browser understøttelse
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Forrige side fontFamily
- Næste side fontStyle
- Gå tilbage til forrige niveau HTML DOM Style Object