Style fontStyle Property
Example
Set the font for an element to "italic":
document.getElementById("demo").style.fontStyle = "italic";
Try it Yourself »
Definition and Usage
The fontStyle property sets or returns whether the style of the font is normal, italic or oblique.
Browser Support
Property | |||||
---|---|---|---|---|---|
fontStyle | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the fontStyle property:
object.style.fontStyle
Set the fontStyle property:
object.style.fontStyle = "normal|italic|oblique|initial|inherit"
Property Values
Value | Description |
---|---|
normal | Font is normal. This is default |
italic | Font is in italic |
oblique | Font is in oblique |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Technical Details
Default Value: | normal |
---|---|
Return Value: | A String, representing the font style of the text in the element |
CSS Version | CSS1 |
More Examples
Example
A demonstration of possible values:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontStyle = listValue;
Try it Yourself »
Example
Return the font style of an element:
alert(document.getElementById("demo").style.fontStyle);
Try it Yourself »
Related Pages
CSS tutorial: CSS Font
CSS reference: font-style property
HTML DOM reference: font property
❮ Style Object