Style fontStyleProperty

Style 对象参考手册Style Object

Definition and Usage

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

Syntax

Set the fontStyle property:

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

Return the fontStyle property:

Object.style.fontStyle

Value Description
normal Default. The font is normal.
italic The font is italic.
oblique The font is oblique.
inherit The value of the fontStyle property 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

Change the font to italic:

function displayResult(){
    document.getElementById("p1").style.fontStyle="italic";
}

Try it Yourself »


Style 对象参考手册Style Object Other Extensions