Style fontStyle Property

Definition and Usage

fontStyle The attribute sets or returns the style of the font as normal, italic, or oblique.

See Also:

CSS Tutorial:CSS Font

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";

Try It Yourself

Example 2

Demonstration of possible values:

var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("myP").style.fontStyle = listValue;

Try It Yourself

Example 3

Returns the font style of the <p> element:

alert(document.getElementById("myP").style.fontStyle);

Try It Yourself

Syntax

Return fontStyle property:

object.style.fontStyle

Set fontStyle property:

object.style.fontStyle = "normal|italic|oblique|initial|inherit"

Property 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

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support