X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Style fontWeight Property

Style Object Reference Style Object

Example

Set the font weight for a <p> element to "900":

document.getElementById("myP").style.fontWeight="900";

Try it yourself »


Definition and Usage

The fontWeight property sets or returns how thick or thin characters in a text should be displayed.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The fontWeight property is supported in all major browsers.


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("myP").style.fontWeight=listValue;

Try it yourself »

Example

Return the font weight of a <p> element:

alert(document.getElementById("myP").style.fontWeight);

Try it yourself »


Related Pages

CSS tutorial: CSS Font

CSS reference: font-weight property

HTML DOM reference: font property


Style Object Reference Style Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook