Click to Rate and Give Feedback
Properties
 fontWeight Property
fontWeight Property

Gets the numeric weight of the font of the object.

Syntax

HTMLN/A
Scripting[ nWeight = ] object.currentStyle.fontWeight

Possible Values

nWeightInteger that receives one of the following values.
100Font is at least as light as the 200 weight.
200Font is at least as bold as the 100 weight and at least as light as the 300 weight.
300Font is at least as bold as the 200 weight and at least as light as the 400 weight.
400Default. Font is normal.
500Font is at least as bold as the 400 weight and at least as light as the 600 weight.
600Font is at least as bold as the 500 weight and at least as light as the 700 weight.
700Font is bold.
800Font is at least as bold as the 700 weight and at least as light as the 900 weight.
900Font is at least as bold as the 800 weight.

The property is read-only. The property has a default value of 400. The Cascading Style Sheets (CSS) attribute is not inherited.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.

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.

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.

Example

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.

<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>
This feature requires Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Standards Information

There is no public standard that applies to this property.

Applies To

A, ADDRESS, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, currentStyle, CUSTOM, DD, defaults, 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, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP

See Also

fontWeight, font
Tags What's this?: Add a tag
Community Content
 
Add Community Content
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker