CSS font-weight
The CSS font-weight
property is used for specifying the weight of the font. You can specify a font as being bold
, or another relevant value.
Although the font-weight
property is typically used for specifying bold text, it can also be used for specifying a particular weight of a font face. Many typefaces come in a range of weights. You can specify that the body text is displayed in a light typeface, such as 300
, and article ledes are displayed in say, 500
. This assumes that such weights are available for the particular font face being used.
When a weight is specified for which no face exists, a face with a nearby weight is used. In general, bold weights map to faces with heavier weights and light weights map to faces with lighter weights.
If a bold font has been specified for which there is no bold face, the user agent will usually synthesize the effect. This can be disabled with the font-synthesis
property.
Tip: Use font
to set the most common font properties in one go.
Syntax
Possible Values
normal
- Same as
400
. bold
- Same as
700
. bolder
- Specifies a bolder weight than the inherited value.
lighter
- Specifies a lighter weight than the inherited value.
100
- Thin.
200
- Extra Light (Ultra Light).
300
- Light.
400
- Normal.
500
- Medium.
600
- Semi Bold (Demi Bold).
700
- Bold.
800
- Extra Bold (Ultra Bold).
900
- Black (Heavy).
In addition, all CSS properties also accept the following CSS-wide keyword values as the sole component of their property value:
initial
- Represents the value specified as the property's initial value.
inherit
- Represents the computed value of the property on the element's parent.
unset
- This value acts as either
inherit
orinitial
, depending on whether the property is inherited or not. In other words, it sets all properties to their parent value if they are inheritable or to their initial value if not inheritable.
General Information
- Initial Value
normal
- Applies To
- All elements
- Inherited?
- Yes
- Media
- Visual
- Animatable
- Yes (see example)
Example Code
Official Specifications
- CSS Fonts Module Level 3 (W3C Candidate Recommendation 3 October 2013)
- CSS Level 2.1 (W3C Recommendation 07 June 2011)
- CSS Level 1 (W3C Recommendation 17 Dec 1996)