Click to return to the DHTML, HTML     
font-variant Attribute | ...     form Property     DHTML Properties    
Web Workshop  |  DHTML, HTML & CSS

font-weight Attribute | fontWeight Property


Sets or retrieves the weight of the font of the object.

Syntax

HTML{ font-weight: sWeight }
Scriptingobject.style.fontWeight [ = sWeight ]

Possible Values

sWeight String that specifies one of the following values:
normalFont is normal.
boldFont is bold.
bolderFont is heavier than regular bold.
lighterFont is lighter than normal.
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.
400Font 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/write with a default value of normal; the cascading style sheets (CSS) attribute is inherited.

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

Remarks

Key words 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 400 is equivalent to normal, and 700 is equivalent to bold. A font-weight of bolder or lighter is interpreted relative to the parent object's weight. A value of bolder for text whose parent is normal would set the text to bold.

Internet Explorer 4.0 supports only normal and bold.

Internet Explorer 3.0 supports the font-weight attribute through the font attribute.

Example

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.

Sample Code

<STYLE>
LI { font-weight:bolder }
</STYLE>

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

This example uses inline scripting to set the font weight to bolder when an onmouseover event occurs.

<P STYLE="font-size:14" onmouseover="this.style.fontWeight='bolder'">

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
A, ADDRESS, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, currentStyle, custom, DD, 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

See Also

font



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.