Style fontStyle attribute
- Föregående sida fontSize
- Nästa sida fontVariant
- Gå tillbaka till föregående nivå HTML DOM Style-objekt
Definition and usage
fontStyle
The attribute sets or returns the style of the font as normal, italic, or oblique.
See also:
CSS Tutorial:CSS-teckensnitt
CSS Reference Manual:font-style attribute
HTML DOM Reference Manual:font property
Instance
Example 1
Sets the font of the <p> element to "italic" (italic):
document.getElementById("myP").style.fontStyle = "italic";
Example 2
Demonstration of possible values:
var listValue = selectTag.options[selectTag.selectedIndex].text; document.getElementById("myP").style.fontStyle = listValue;
Example 3
Returns the font style of the <p> element:
alert(document.getElementById("myP").style.fontStyle);
Syntax
Return fontStyle property:
object.style.fontStyle
Set fontStyle property:
object.style.fontStyle = "normal|italic|oblique|initial|inherit"
Attribute value
Value | Description |
---|---|
normal | Font is normal. Default. |
italic | Font is italic. |
oblique | Font slant. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical details
Default value: | normal |
---|---|
Return value: | A string that represents the font style of the text within an element. |
CSS version: | CSS1 |
Webbläsarstöd
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Stöd | Stöd | Stöd | Stöd | Stöd |
- Föregående sida fontSize
- Nästa sida fontVariant
- Gå tillbaka till föregående nivå HTML DOM Style-objekt