The CSS reference

"font-weight" - css property (v. css 1)

  • To specify the weight of a font.
  • Initial value: normal
  • The property is inherited
  • HTML usage: all elements
  • Browsers that support the font-weight - property :
    Internet Explorer Mozilla Firefox Opera Google Chrome Apple Safari

Possible font-weight values:

value Comments CSS
normal The keyword 'normal' is synonymous with the value '400'. 1
bold The keyword 'bold' is synonymous with the value '700'. 1
bolder Selects the next weight that is assigned to a font that is darker than the inherited one. 1
lighter Selects the next lighter keyword with a different font from the inherited one. 1
100
200
300
400
500
600
700
800
900
The values '100' to '900' form an ordered sequence, where each number indicates a weight that is at least as dark as its predecessor. 1
inherit Will inherit the value from parent specification. 2

Property "font-weight" example:

<!DOCTYPE HTML >
<html  >
  <head>
    <title>Test</title>
    <style type="text/css">
      div {border: blue 1px solid; color:black;
           padding: 4px 4px 4px 4px; width: 400px;
      }
      .bold { font-weight: bold; }
      .bolder { font-weight: bolder; }
      .weight100 { font-weight: 400; }
    </style>
  </head>
  <body style="font-size: 14pt" >
    font-weight: bold; <br>
    <div class="bold" >
      The keyword 'bold' is synonymous
      with the value '700'.
    </div>
    <br>font-weight: bolder; <br>
    <div class="bolder" >
      Selects the next weight that is assigned
      to a font that is darker than the
      inherited one.
    </div>
    <br>font-weight: 400; (normal)<br>
    <div class="weight400" >
      The values '100' to '900' form an ordered
      sequence, where each number indicates
      a weight that is at least as dark as
      its predecessor.
    </div>
  </body>
</html>

Javascript access:

// To SET values ([o] is the target object)
[o].style.fontWeight="font-weight values"
// To GET values you must first get the computed style object
// To get that object in IE or Opera:
var cStyle=[o].currentStyle;
// To get that object in Firefox, Chrome or Safari (w3c-type):
var cStyle=window.getComputedStyle([o],null)
// To GET the property value:
var value=cStyle.fontWeight;
/* Chrome will return the keyword if a keyword for weight is set.
   IE, Opera, Firefox and Safari will
   return a weight number if any weight type is set.
   Opera and Safari will return the keyword
   'normal' if the weight is NOT set.*/
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.