Definition and Usage
The font-weight CSS property specifies the weight or boldness of the font. However, some fonts are not available in all weights; some are available only on normal and bold.
- Initialnormal
- Applies toall elements
- Inheritedyes
- Mediavisual
- Computed Valuethe keyword or the numerical value as specified, with bolder and lighter transformed to the real value
- Animatableyes, as a font weight
- Canonical orderthe unique non-ambiguous order defined by the formal grammar
Syntax
Formal syntax: normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
font-weight: normal
font-weight: bold
font-weight: lighter
font-weight: bolder
font-weight: 100
font-weight: 200
font-weight: 300
font-weight: 400
font-weight: 500
font-weight: 600
font-weight: 700
font-weight: 800
font-weight: 900
font-weight: inherit
Values
- normal
- Normal font weight. Same as 400.
- bold
- Bold font weight. Same as 700.
- lighter
- One font weight lighter than the parent element (among the available weights of the font).
- bolder
- One font weight darker than the parent element (among the available weights of the font).
- 100, 200, 300, 400, 500, 600, 700, 800, 900
- Numeric font weights for fonts that provide more than just normal and bold. If the exact weight given is unavailable, then 600-900 use the closest available darker weight (or, if there is none, the closest available lighter weight), and 100-500 use the closest available lighter weight (or, if there is none, the closest available darker weight). This means that for fonts that provide only normal and bold, 100-500 are normal, and 600-900 are bold.
Interpolation
A font-weight
value is interpolated via discrete steps (multiples of 100). The interpolation happens in real number space and is converted to an integer by rounding to the nearest multiple of 100, with values halfway between multiples of 100 rounded towards positive infinity.
Examples
2 |
p { font-weight : bold ; } |
5 |
h 1 { font-weight : 500 ; } |
8 |
span { font-weight : lighter ; } |
Compatibility
Desktop browsers
Feature |
Chrome |
Firefox (Gecko) |
Internet Explorer |
Opera |
Safari (WebKit) |
Basic support |
2.0 |
1.0 (1.7 or earlier) |
3.0 |
3.5 |
1.3 |
Mobile browsers
Feature |
Android |
Firefox Mobile (Gecko) |
IE Phone |
Opera Mobile |
Safari Mobile |
Basic support |
1.0 |
1.0 (1.0) |
6.0 |
6.0 |
3.1 |