Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Style fontStyle Property

Style fontStyle Property

Style Object Reference The Style object


Definition and Usage

The fontStyle property sets or returns whether the font style is normal (normal), italic (italic) or oblique (oblique).

Syntax

Sets the fontStyle property:

Object.style.fontStyle="normal|italic|oblique|inherit"

Returns the fontStyle property:

Object.style.fontStyle

Value Description
normal Default. The font is normal (normal).
italic The font is italic (italic).
oblique The font is oblique (oblique).
inherit The fontStyle property value is inherited from the parent element.

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the fontStyle property.

**Note:** IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".


Example

Example

Changes the font to italic:

function displayResult(){

    document.getElementById("p1").style.fontStyle="italic";

}

Try it »


Style Object Reference The Style object