Sets or retrieves up to six separate font properties of the object.
Syntax
HTML { font: sFont } Scripting object.style.font [ = sFont ]
Possible Values
sFont String that specifies up to six of the space-delimited values listed first in the following table, plus one or more of the values listed after them:
font-style Any of the range of font-style values available to the fontStyle property. font-variant Any of the range of font-variant values available to the fontVariant property. font-weight Any of the range of font-weight values available to the fontWeight property. font-size Any of the range of font-size values available to the fontSize property. line-height Any of the range of line-height values available to the lineHeight property. font-family Any of the range of font-family values available to the fontFamily property. caption Text font used in objects that have captions (buttons, labels, and so on). icon Text font used in icon labels. menu Text font used in menus. messagebox Text font used in dialog boxes. smallcaption Text font used in small controls. statusbar Text font used in window status bars. The property is read/write with the default value set by the browser; the cascading style sheets (CSS) attribute is inherited.
Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see Dynamic Properties.
Remarks
This is a composite property that specifies up to six font values, in the following order: font-style, font-variant, font-weight, font-size, line-height, font-family. Setting the font property also sets the component properties. In this case, the string must be a combination of valid values for the component properties, with no more than one value per property. If the string does not contain a value for a component property, that property is set to its default.
Example
The following examples use the font attribute and the font property to change font characteristics.
This example uses an inline style sheet to set the font attributes.
Sample Code
<SPAN STYLE="font:italic normal bolder 12pt Arial"> : </SPAN>This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.This example uses inline scripting to set the font properties.
<DIV onmouseover="this.style.font = 'italic small-caps bold 12pt serif'"> : </DIV>
Applies To
A, ADDRESS, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, custom, DD, 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
See Also
CSS Length Units