font Attribute | font Property

DHTML, HTML, & CSS

font Attribute | font Property


Sets or retrieves up to six separate font properties of the object.

Syntax

HTML{ font: sFont }
Scriptingobject.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-styleAny of the range of font-style values available to the fontStyle property.
font-variantAny of the range of font-variant values available to the fontVariant property.
font-weightAny of the range of font-weight values available to the fontWeight property.
font-sizeAny of the range of font-size values available to the fontSize property.
line-heightAny of the range of line-height values available to the lineHeight property.
font-familyAny of the range of font-family values available to the fontFamily property.
captionText font used in objects that have captions (buttons, labels, and so on).
iconText font used in icon labels.
menuText font used in menus.
messageboxText font used in dialog boxes.
smallcaptionText font used in small controls.
statusbarText 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 propertiesInternet Link.

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.
Microsoft Internet Explorer

This example uses inline scripting to set the font properties.

<DIV onmouseover="this.style.font = 'italic small-caps bold 12pt serif'">
:
</DIV>

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.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
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

Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.