HTML | DOM Style fontStyle Property
HTML DOM Style fontStyle Property is used to set or get font syle of an element dynamically.
Syntax:
- To set the fontStyle property :
object.style.fontStyle = normal|italic|oblique|initial|inherit;
- To get fontStyle property value:
object.style.height
Property values:
| Value | Description<> |
|---|---|
| normal | |
| italic | |
| oblique | |
| intial | |
| inherit |
Return Value: String that gives fontStyle of the element.
Example :
<!DOCTYPE html> <html> <head> <title> HTML | DOM Style fontStyle Property </title> <style> #gfg { color: green; font-size: 100px; font-style: normal; } </style> </head> <body> <center> <button onclick="changeStyle()"> Click to change style </button> <!-- Script to change the fontStyle --> <script> function changeStyle() { document.getElementById("gfg").style.fontStyle = "italic"; } </script> <p id="gfg"> Geeks For Geeks </p> </center> </body> </html> |
Output
Before clicking on the button:

After clicking on the button:

Example:
<!DOCTYPE html> <html> <head> <title> HTML | DOM Style fontStyle Property </title> <style> #gfg { color: green; font-size: 50px; font-style: normal; } </style> </head> <body> <center> <br> <button onclick="changeStyle()"> Click to change style </button> <br /> <br /> <!-- Script to change the fontStyle --> <script> function changeStyle() { document.getElementById("gfg").style.fontStyle = "oblique"; } </script> <div id="gfg"> HTML DOM fontStyle Property </div> </center> </body> </html> |
Output:
Before clicking on the button:

After clicking on the button:
Supported Browsers: The browser supported by HTML | DOM Style fontStyle Property are listed below:
- Google Chrome 1.0
- INternet Explorer/Edge 4.0
- Firefox 1.0
- Opera 7.0
- Safari 1.0
Recommended Posts:
- HTML | DOM Style right Property
- HTML | DOM Style top Property
- HTML | DOM Style maxWidth Property
- HTML | DOM Style flexShrink Property
- HTML | DOM Style font Property
- HTML | DOM Style justifyContent Property
- HTML | DOM Style fontFamily Property
- HTML | DOM Style listStylePosition Property
- HTML | DOM Style fontSizeAdjust Property
- HTML | DOM Style borderTopLeftRadius Property
- HTML | DOM Style transitionDelay Property
- HTML | DOM Style columnRuleColor Property
- HTML | DOM Style textShadow Property
- HTML | DOM Style borderImageSlice Property
- HTML | DOM Style fontVariant Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



