Latest web development tutorials

HTML DOM Style fontStyle property

Style Object Reference Style Objects

Definition and Usage

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

grammar

Setting fontStyle properties:

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

Back fontStyle properties:

Object.style.fontStyle

描述
normal 默认。字体是 normal(正常的)。
italic 字体是 italic(斜体)。
oblique 字体是 oblique(倾斜的)。
inherit fontStyle 属性的值从父元素继承。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support fontStyle property.

Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".


Examples

Examples

Change the font to italic:

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

try it"


Style Object Reference Style Objects