The CSS font-weight
property is fundamental to web typography, controlling how thick or thin your text appears. Whether you’re creating subtle emphasis or bold headlines, understanding font-weight values is essential for professional web design.
What is CSS Font-Weight?
The font-weight
property specifies the weight (thickness) of font characters. It accepts both keyword values like bold
and normal
, as well as numeric values from 100 to 900.
font-weight: normal | bold | bolder | lighter | 100-900 | initial | inherit;
Font-Weight Keyword Values
Normal Weight
The normal
value represents the default font weight, equivalent to numeric value 400. This is the standard weight for body text and general content.
Example:
.normal-text {
font-weight: normal;
}
This text uses normal font-weight (400)
Bold Weight
The bold
keyword creates thick, prominent text equivalent to numeric value 700. It’s perfect for headings, emphasis, and important information.
Example:
.bold-text {
font-weight: bold;
}
This text uses bold font-weight (700)
Bolder and Lighter Values
The bolder
and lighter
values are relative to the parent element’s font weight. They increase or decrease the weight by one step in the font-weight scale.
Example:
.parent {
font-weight: 400;
}
.bolder-child {
font-weight: bolder; /* Becomes 700 */
}
.lighter-child {
font-weight: lighter; /* Becomes 300 */
}
Parent text (400)
Bolder child text
Lighter child text
Numeric Font-Weight Values
Numeric values provide precise control over font weight, ranging from 100 (thin) to 900 (black/heavy). Each increment of 100 represents a different weight level.
Complete Numeric Scale
Font-Weight Scale Demonstration:
100 – Thin/Hairline
200 – Extra Light
300 – Light
400 – Normal/Regular
500 – Medium
600 – Semi Bold
700 – Bold
800 – Extra Bold
900 – Black/Heavy
Common Numeric Values
While the full range is available, certain numeric values are most commonly used in web design:
Practical Example:
.thin-text { font-weight: 300; }
.normal-text { font-weight: 400; }
.medium-text { font-weight: 500; }
.bold-text { font-weight: 700; }
.extra-bold { font-weight: 800; }
Light text for elegant designs
Normal text for body content
Medium text for subtle emphasis
Bold text for headings
Extra bold for strong impact
Interactive Font-Weight Demo
Try Different Font Weights:
Sample text to test font weights
Font-Weight with Different Font Families
Font weight appearance varies significantly between different font families. Some fonts have extensive weight ranges, while others may only support normal and bold.
Font Family Comparison:
.arial-font {
font-family: Arial, sans-serif;
font-weight: 700;
}
.georgia-font {
font-family: Georgia, serif;
font-weight: 700;
}
.system-font {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
font-weight: 700;
}
Bold Arial Font
Bold Georgia Font
Bold System Font
Variable Fonts and Font Weight
Variable fonts offer infinite font-weight values between defined ranges, providing unprecedented typography control. Instead of discrete weight steps, you can use any value within the font’s supported range.
Variable Font Example:
@import url('https://fonts.googleapis.com/css2?family=Inter:[email protected]&display=swap');
.variable-font {
font-family: 'Inter', sans-serif;
font-weight: 350; /* Any value between 100-900 */
}
Custom weight value (350) with variable fonts
Browser Compatibility and Fallbacks
Font-weight has excellent browser support, but it’s important to understand how browsers handle unavailable weights:
Browser Behavior:
- If a specific numeric weight isn’t available, browsers use the closest available weight
- Values 100-500 generally map to normal (400) if unavailable
- Values 600-900 typically map to bold (700) if unavailable
- Always provide fallback font stacks for consistent rendering
Best Practices for Font-Weight
Typography Hierarchy
Create clear visual hierarchy using strategic font-weight combinations:
Hierarchical Design Example:
h1 { font-weight: 800; }
h2 { font-weight: 700; }
h3 { font-weight: 600; }
h4 { font-weight: 500; }
p { font-weight: 400; }
.subtitle { font-weight: 300; }
Main Heading (800)
Section Heading (700)
Subsection Heading (600)
Minor Heading (500)
Body paragraph text (400)
Subtitle or caption text (300)
Accessibility Considerations
Ensure sufficient contrast between different font weights for readability:
Accessibility Tips:
- Avoid using only font-weight to convey important information
- Test font-weight combinations with screen readers
- Ensure sufficient color contrast with lighter font weights
- Consider users who may have difficulty distinguishing subtle weight differences
Common Font-Weight Use Cases
Navigation and UI Elements
Navigation Example:
.nav-link {
font-weight: 500;
transition: font-weight 0.2s ease;
}
.nav-link:hover,
.nav-link.active {
font-weight: 700;
}
Button Styling
Button Weight Examples:
.btn-primary { font-weight: 600; }
.btn-secondary { font-weight: 400; }
.btn-outline { font-weight: 500; }
Performance Considerations
Font-weight choices can impact web performance, especially when using web fonts:
Performance Tips:
- Load only the font weights you actually use
- Use
font-display: swap
for better loading performance - Consider system fonts for better performance
- Preload critical font files
- Use variable fonts when you need multiple weights
Advanced Font-Weight Techniques
CSS Custom Properties
Dynamic Font Weights:
:root {
--heading-weight: 700;
--body-weight: 400;
--accent-weight: 600;
}
.heading { font-weight: var(--heading-weight); }
.body { font-weight: var(--body-weight); }
.accent { font-weight: var(--accent-weight); }
@media (max-width: 768px) {
:root {
--heading-weight: 600;
--accent-weight: 500;
}
}
Animation and Transitions
Animated Font Weight:
.animated-text {
font-weight: 400;
transition: font-weight 0.3s ease;
}
.animated-text:hover {
font-weight: 700;
}
Hover to see font-weight animation
Troubleshooting Font-Weight Issues
Common Problems and Solutions
Font Weight Not Working?
- Check font availability: Ensure the font family supports the desired weight
- Verify font loading: Make sure web fonts are properly loaded
- Browser rendering: Some browsers may not support all numeric values
- CSS specificity: Check if other styles are overriding your font-weight
Conclusion
Mastering CSS font-weight is essential for creating effective typography hierarchies and enhancing user experience. Whether using keyword values like bold
and normal
or precise numeric values from 100 to 900, understanding how font-weight works helps you create more engaging and accessible web designs.
Remember to consider browser compatibility, performance implications, and accessibility when implementing font-weight in your projects. With proper use of font-weight, you can significantly improve your website’s visual hierarchy and overall design quality.
Key Takeaways:
- Use numeric values (100-900) for precise control
- Keyword values (normal, bold) work across all browsers
- Variable fonts offer unlimited weight possibilities
- Always consider performance and accessibility
- Test font-weight across different devices and browsers