Gets the numeric weight of the font of the object.
Syntax
HTML | N/A |
---|
Scripting | [ nWeight = ] object.currentStyle.fontWeight |
---|
Possible Values
nWeight | Integer that
receives one of the following 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 | Default. 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-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 >
<p id="p1">Click the buttons below.</p>
<button >Lighter</button>
<button >Normal</button>
<button >Bold</button>
<button >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