fontWeight property

Gets the numeric weight of the font of the object.

Syntax

fontWeight: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900

Property values

100

Font is at least as light as the 200 weight.

200

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

300

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

400

Font is normal.

500

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

600

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

700

Font is bold.

800

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

900

Font is at least as bold as the 800 weight.

CSS information

Applies ToAll elements
Mediavisual
Inheritedno
Initial Value

Remarks

The fontWeight property of the currentStyle object is read-only. To set the value, use the fontWeight property of the style object. Unlike the style object, the fontWeight property of the currentStyle object only returns numeric values.

Unlike fontWeight, fontWeight is read-only and returns only numeric values.

The values for fontWeight 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 fontWeight settings because the system chooses the closest match.

Examples

The following example demonstrates how to set the fontWeight property of a p element. The script reads the fontWeight property of the currentStyle object and displays the value in a span element.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/fontWeight_1.htm


<body onload="setInterval('s1.innerText = p1.currentStyle.fontWeight',200)">
<p id="p1">Click the buttons below.</p>
<button onclick="p1.style.fontWeight='lighter';">Lighter</button>
<button onclick="p1.style.fontWeight='normal';">Normal</button>
<button onclick="p1.style.fontWeight='bold';">Bold</button>
<button onclick="p1.style.fontWeight='bolder';">Bolder</button>
<br>Current Weight: <span id="s1"></span>
</body>

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll

See also

currentStyle
defaults
Reference
fontWeight
font

 

 

Show:
© 2014 Microsoft. All rights reserved.