Javascript examples for CSS Style Property:fontWeight
The fontWeight property sets or gets how thick or thin characters of text.
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. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | normal |
Return Value: | A String, representing the boldness of the font |
CSS Version | CSS1 |
Set the font weight for a <p> element to "900":
<!DOCTYPE html> <html> <body> <p id="myP" style="font-weight:bold">This is a paragraph.</p> <button type="button" onclick="myFunction()">Test</button> <script> function myFunction() {// w ww . j ava 2s . com document.getElementById("myP").style.fontWeight = '900'; } </script> </body> </html>