Sets or retrieves the name of the font used for text in the object.
Syntax
HTML { font-family: sFamily } Scripting object.style.fontFamily [ = sFamily ]
Possible Values
sFamily String that specifies one of the following values:
family-name Any of the available font families supported by the browser (for example, Times, Helvetica, Zapf-Chancery, Western, or Courier). generic-name Any of the following font families: serif, sans-serif, cursive, fantasy, or monospace. 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
The value is a prioritized list of font family names and/or generic family names. List items are separated by commas to minimize confusion between multiple-word font family names. If the font family name contains white space, it should be quoted with single or double quotation marks; generic font family names are values and, accordingly, no quotes should be used.
Because you don't know which fonts users have installed, you should provide a list of alternatives with a generic font family at the end of the list. This list can include embedded fonts. For more information about embedding fonts, see the @font-face rule.
If fantasy is specified for generic-name, the text renders in the default font.
Example
The following examples use the font-family attribute and the fontFamily property to change font characteristics.
This example uses a call to an embedded style sheet to set the font family.
Sample Code
<STYLE> P { font-family:"Arial"} .other { font-family:"Courier"} </STYLE>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 change the font family when an onmousedown event occurs.
<DIV onmousedown="this.style.fontFamily='Courier'">
Applies To
A, ADDRESS, B, BASEFONT, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, currentStyle, 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