Style fontSize Attribute
- Previous Page fontFamily
- Next Page fontStyle
- Go to the Previous Level HTML DOM Style Object
Definition and Usage
fontSize
Sets or returns the font size of the text.
See Also:
CSS Tutorial:CSS Font
CSS Reference Manual:font-size Attribute
HTML DOM Reference Manual:font Property
Instance
Example 1
Sets 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
Returns 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 |
---|---|
|
Sets the font size to a different fixed size, from xx-small to xx-large. |
smaller | Decreases the font size by a relative unit. |
larger | Increases the font size by a relative unit. |
length | Define the font size with a length unit. |
% | Sets the font size to a percentage of the parent element's font size. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical Details
Default value: | medium |
---|---|
Return value: | A string that represents the font size of the element's text. |
CSS Version: | CSS1 |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page fontFamily
- Next Page fontStyle
- Go to the Previous Level HTML DOM Style Object