fontWeight property

Specifies the weight of the font of the object.

 

Syntax

Integer value = object.put_fontWeight( v);Integer value = object.get_fontWeight(* sWeight);

Property values

Type: BSTR

normal (normal)

Font is normal.

bold (bold)

Font is bold.

bolder (bolder)

Font is at least as bold as the default bold weight.

lighter (lighter)

Font is lighter than normal.

100 (100)

Font is at least as light as the 200 weight.

200 (200)

Font is at least as bold as the 100 weight and at least as light as the 300 weight.

300 (300)

Font is at least as bold as the 200 weight and at least as light as the 400 weight.

400 (400)

Font is normal.

500 (500)

Font is at least as bold as the 400 weight and at least as light as the 600 weight.

600 (600)

Font is at least as bold as the 500 weight and at least as light as the 700 weight.

700 (700)

Font is bold.

800 (800)

Font is at least as bold as the 700 weight and at least as light as the 900 weight.

900 (900)

Font is at least as bold as the 800 weight.

String format

normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900

CSS information

Applies To All elements
Media visual
Inherited 1
Initial Value normal

Standards information

Remarks

Keywords for IHTMLCSSStyleDeclaration::fontWeight values are mapped to specific font variations depending on the fonts that are installed on the user's computer. In many cases, the user cannot see the difference between different IHTMLCSSStyleDeclaration::fontWeight settings because the system chooses the closest match.

Setting the IHTMLCSSStyleDeclaration::fontWeight to 400 is equivalent to normal, and to 700 is equivalent to bold. An IHTMLCSSStyleDeclaration::fontWeight of bolder or lighter is interpreted relative to the parent object's weight. A value of bolder for text whose parent is normal sets the text to bold.

To convert these strings to numeric equivalents, use the read-only IHTMLCurrentStyle::fontWeight property.

Examples

This example uses IHTMLCSSStyleDeclaration::fontWeight to display text in the default body element text font weight (bold), then display text in a lighter font weight.

body {
  font-weight: bold;
  font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif;
}
.lighter {
  font-weight: lighter;
}
<body>
  <p>Lorem ipsum dolor sit amet... (<em>font-weight: bold</em>)</p>
  <p class="lighter">Lorem ipsum dolor sit amet... (<em>font-weight: lighter</em>)</p>
</body>

The following image shows the result:

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll

See also

IHTMLCSSStyleDeclaration::font