Export (0) Print
Expand All

font property

Specifies a combination of separate IHTMLStyle::font properties of the object. Alternatively, sets or retrieves one or more of six user-preference fonts.


Integer value = object.put_font( v);Integer value = object.get_font(* p);

Property values

Type: BSTR

Up to six of the following space-delimited property values. Alternatively, sets or retrieves the six listed text fonts.

font-style (normal)

Any of the range of font-style values available to the IHTMLStyle::fontStyle property.

font-variant (normal)

Any of the range of font-variant values available to the IHTMLStyle::fontVariant property.

font-weight (normal)

Any of the range of font-weight values available to the IHTMLStyle::fontWeight property.

font-size (medium)

Any of the range of font-size values available to the IHTMLStyle::fontSize property. When this value is an integer followed by a percent (%), the value is a percentage of the parent object's font size.

line-height (normal)

Any of the range of line-height values available to the IHTMLStyle::lineHeight property. When used with the IHTMLStyle::font property, this attribute must include a slash (/) before the value. Line height percentage values are calculated as a percentage of the font size of the element itself, not of the parent.

font-family ("Times New Roman")

Any of the range of font-family values available to the IHTMLStyle::fontFamily property. This property can be set to multiple comma-separated values. Its default value depends on user settings.


User-preference font used in objects that have captions—buttons, labels, and so on.


User-preference font used in icon labels.


User-preference font used in menus.


User-preference font used in dialog boxes.


User-preference font used in small controls.


User-preference font used in window status bars.

String format

[ [ font-style || font-variant || font-weight ]? font-size [ / line-height ]? font-family ] | caption | icon | menu | message-box | small-caption | status-bar

CSS information

Applies ToAll elements
Initial Valuethe concatenation of the initial values of its longhand properties


This is a composite property that specifies up to six font values. The font-style, font-variant, and font-weight values may appear in any order before font-size. However, the font-size, line-height, and font-family properties must appear in the order listed. Setting the IHTMLStyle::font property also sets the component properties. In this case, the string must be a combination of valid values for the component properties; only font-family may have more than one value. If the string does not contain a value for a component property, that property is set to its default, regardless of prior settings for that component property.

As of Microsoft Internet Explorer 6, when you use the !DOCTYPE declaration to specify standards-compliant mode, the following conditions apply to this property.

  1. The font-size and font-family values must be declared. If font-size and font-family are not declared, or are not in the correct order, the IHTMLStyle::font property is ignored.
  2. All specified values must appear in the correct order. Otherwise, the IHTMLStyle::font property is ignored.
  3. In standards-compliant mode, the default font-size is small, not medium. If not explicitly set, font-size returns a point value.

For more information about standards-compliant parsing and the !DOCTYPE declaration, see CSS Enhancements in Internet Explorer 6.


This example displays three lines of text using different IHTMLStyle::font settings.

body {
  font: Garamond, serif;
.sans-serif {
  font: italic small-caps 12pt Arial, sans-serif;
.monospace {
  font: bold 14pt Courier, monospace;

  <p>Lorem ipsum dolor sit amet... (font: Garamond, serif)</p>
  <p class="sans-serif">Lorem ipsum dolor sit amet... (font: italic small-caps 12pt Arial, sans-serif)</p>
  <p class="monospace">Lorem ipsum dolor sit amet... (font: bold 14pt Courier, monospace)</p>

The following image shows the result. The first line of text shows the default body element IHTMLStyle::font setting that specifies a font from a serif font family. The second line of text shows a IHTMLStyle::font setting that specifies an italic font style, small-caps font variant, 12-point font size, and a font from a sans-serif font family. The third line of text shows a IHTMLStyle::font setting that specifies a bold font weight, 14-point font size, and a font from a monospace font family:

An image showing text with different font property settings.


Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]







See also

CSS Values and Units Reference



Community Additions

© 2014 Microsoft