Javascript examples for CSS Style Property:fontSize
The fontSize property sets or gets the font size.
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. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | medium |
Return Value: | A String, representing the font size of the text in the element |
CSS Version | CSS1 |
Set the font size for a <p> element to "xx-large":
<!DOCTYPE html> <html> <body> <p id="myP">This is a paragraph.</p> <button type="button" onclick="myFunction()">Adjust font size</button> <script> function myFunction() {//from w w w. j a v a 2s . co m document.getElementById("myP").style.fontSize = "xx-large"; } </script> </body> </html>