Style fontWeight Property
Example
Set the font weight for an element to "900":
document.getElementById("demo").style.fontWeight = "900";
Try it Yourself »
Description
The fontWeight property sets or returns how thick or thin characters in a text should be displayed.
Browser Support
Property | |||||
---|---|---|---|---|---|
fontWeight | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the fontWeight property:
object.style.fontWeight
Set the fontWeight property:
object.style.fontWeight = "normal|lighter|bold|bolder|value|initial|inherit"
Property Values
Value | Description |
---|---|
normal | Font is normal. This is default |
lighter | Font is lighter |
bold | Font is bold |
bolder | Font is bolder |
100 200 300 400 500 600 700 800 900 |
Defines from light to bold characters. 400 is the same as normal, and 700 is the same as bold |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Technical Details
Default Value: | normal |
---|---|
Return Value: | A String, representing the boldness of the font |
CSS Version | CSS1 |
More Examples
Example
A demonstration of possible values:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontWeight = listValue;
Try it Yourself »
Example
Return the font weight of an element:
alert(document.getElementById("demo").style.fontWeight);
Try it Yourself »
Related Pages
CSS tutorial: CSS Font
CSS reference: font-weight property
HTML DOM reference: font property
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.