29. Font Weight and Style
These properties control the boldness and italicization of text.
Font Weight (font-weight)
This property defines how thick or thin characters in the text should be displayed. It can take keywords or numerical values.
Keywords:
normal(usually equivalent to 400)bold(usually equivalent to 700)lighter(relative to parent)bolder(relative to parent)
Numerical Values (100 to 900):
Font families typically support the following standard weights:
| Value | Weight Name |
|---|---|
| 100 | Thin/Hairline |
| 400 | Normal/Regular |
| 700 | Bold |
| 900 | Black/Heavy |
css .main-heading { font-weight: 700; }
.thin-text { font-weight: 200; /* Only works if the font file includes this weight! */ }
Critical Note: The numerical weight you set will only work if the corresponding font file for that weight was loaded via @font-face or Google Fonts. If you request 200 but only loaded 400 and 700, the browser might default to 400.
Font Style (font-style)
This property sets the style of the font, usually for italic text.
normalitalic(uses the specialized italic version of the font, if available)oblique(browser artificially slants the regular font)
css blockquote { font-style: italic; }