Style fontSize attribute
- Προηγούμενη Σελίδα fontFamily
- Επόμενη Σελίδα fontStyle
- Επιστροφή στο Προηγούμενο επίπεδο Όντα Style HTML DOM
Definition and usage
fontSize
Set or return the font size of the text.
See also:
CSS Tutorial:CSS Γραμματοσειρά
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 a length unit. |
% | 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: | A string representing the font size of the element's text. |
CSS Version: | CSS1 |
Υποστήριξη Περιηγητή
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη |
- Προηγούμενη Σελίδα fontFamily
- Επόμενη Σελίδα fontStyle
- Επιστροφή στο Προηγούμενο επίπεδο Όντα Style HTML DOM