font-weight Attribute | fontWeight Property
Gets or sets the weight of the font of the object.
Syntax
CSS { font-weight : sWeight } Scripting [ sWeight = ] object.style.fontWeight
Possible Values
sWeight String that specifies or receives one of the following values.
normal- Font is normal.
bold- Font is bold.
bolder- Font is at least as bold as the default
boldweight.lighter- Font is lighter than normal.
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.
The property is read/write. The property has no default value. The Cascading Style Sheets (CSS) attribute is inherited.
DHTML expressions can be used in place of the preceding value(s). As of Internet Explorer 8, expressions are supported in IE7 Standards mode and IE5 (Quirks) mode only. For more information, see About Dynamic Properties and Defining Document Compatibility.
Remarks
Keywords for font-weight 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 font-weight settings because the system chooses the closest match.
Setting the font-weight to
400is equivalent tonormal, and to700is equivalent tobold. An font-weight ofbolderorlighteris interpreted relative to the parent object's weight. A value ofbolderfor text whose parent is normal sets the text to bold.Microsoft Internet Explorer 4.0 supports only
normalandbold.Internet Explorer 3.0 supports the font-weight attribute through the font attribute.
Examples
The following examples use the font-weight attribute and the fontWeight property to change the font weight.This example uses li as a selector in an embedded (global) style sheet to set the font weight to
bolder.<STYLE> LI { font-weight:bolder } </STYLE>Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/font-weight.htm
This example uses inline scripting to set the font weight to
bolderwhen an onmouseover event occurs.<P STYLE="font-size:14" onmouseover="this.style.fontWeight='bolder'">Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/fontWeight.htm
Standards Information
This property is defined in Cascading Style Sheets (CSS), Level 1 (CSS1).
Applies To
A, ADDRESS, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, CSSStyleDeclaration, 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, runtimeStyle, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, style, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP, CSSCurrentStyleDeclaration Constructor, CSSRuleStyleDeclaration Constructor, CSSStyleDeclaration Constructor
See Also
font