1 out of 2 rated this helpful - Rate this topic

font-style Attribute | fontStyle Property

Gets or sets the font style of the object as italic, normal, or oblique.

Syntax

CSS { font-style : sStyle }
Scripting [ sStyle = ] object.style.fontStyle

Possible Values

sStyle String that specifies or receives one of the following values.
normal
Default. Font is normal.
italic
Font is italic.
oblique
Font is italic.

The property is read/write for all objects except the following, for which it is read-only: currentStyle. The property has a default value of normal. The Cascading Style Sheets (CSS) attribute is inherited.

DHTML expressions can be used in place of the preceding value(s). As of Internet Explorer 8, expressions are supported in IE7 Standards mode and IE5 (Quirks) mode only. For more information, see About Dynamic Properties and Defining Document Compatibility.

Remarks

The oblique value is available as of Microsoft Internet Explorer 4.0. Internet Explorer 4.0 renders italic and oblique identically.

While, Windows Internet Explorer is shipped with a default fontStyle, this default can be changed by accessing Internet Options.

Examples

The following example shows how to use hn as a selector to set the font style to italic in H3 headings.


<STYLE>
    H3 { font-style:italic }
</STYLE>

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/font-style.htm

The following example shows how to use inline scripting to set the font style to italic when an onmousedown event occurs.


<DIV onmousedown="this.style.fontStyle='italic'"> 

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/fontStyle.htm

Standards Information

This property is defined in Cascading Style Sheets (CSS), Level 1 (CSS1).

Applies To

A, ADDRESS, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, CSSStyleDeclaration, currentStyle, CUSTOM, DD, defaults, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FORM, hn, HTML, I, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, ISINDEX, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, runtimeStyle, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, style, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP, CSSCurrentStyleDeclaration Constructor, CSSRuleStyleDeclaration Constructor, CSSStyleDeclaration Constructor

See Also

font
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ