🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEcss

css Documentation

LOADING ENGINE...

Font-weight

AI & DATA SCIENCE // font-weight

The font-weight property sets the thickness, or boldness, of an element's text, accepting keywords like normal and bold, or numeric values from 100 to 900 for finer-grained control.

Syntax

font-weight: normal | bold | 100-900;

Deep Dive Course

normal corresponds to the numeric value 400, and bold corresponds to 700, but a font-family's actual available weights depend entirely on which specific font files were loaded or are installed — requesting a numeric weight, like 500, that a given font doesn't actually provide a distinct file for typically causes the browser to render the nearest weight it does have, rather than genuinely synthesizing an in-between weight, meaning font-weight: 500 might visually look identical to 400 if the font family only ships regular and bold variants.

1Understanding Font-weight

normal corresponds to the numeric value 400, and bold corresponds to 700, but a font-family's actual available weights depend entirely on which specific font files were loaded or are installed — requesting a numeric weight, like 500, that a given font doesn't actually provide a distinct file for typically causes the browser to render the nearest weight it does have, rather than genuinely synthesizing an in-between weight, meaning font-weight: 500 might visually look identical to 400 if the font family only ships regular and bold variants.

💡

Requesting a specific numeric font-weight, like 500 or 600, only actually looks different from the nearest available weight if that font family specifically includes a font file for that weight — check the font's actual available weights, from Google Fonts or wherever it's sourced, rather than assuming every numeric value between 100 and 900 will render distinctly.

editor.html
h1 {
  font-weight: bold;
}

p {
  font-weight: normal;
}
localhost:3000

2Practical Example

Here is a real-world application of Font-weight showing how it is used in production CSS code.

editor.html
@font-face {
  font-family: 'CustomFont';
  src: url('custom-400.woff2');
  font-weight: 400;
}

.text {
  font-family: 'CustomFont';
  font-weight: 600;
}
localhost:3000

3Best Practices

Follow these guidelines when working with Font-weight:

1. Check which specific numeric weights a font family actually provides before relying on an in-between value like 500 or 600 to look visually distinct

2. Load only the specific font-weight values a design actually uses via @font-face or a font service like Google Fonts, rather than the entire available weight range, to reduce page load size

3. Use the bold keyword, or its equivalent 700, as the default choice for standard bold text, reserving finer-grained numeric weights for designs specifically calling for them

⚠️

Tip: Requesting a specific numeric font-weight, like 500 or 600, only actually looks different from the nearest available weight if that font family specifically includes a font file for that weight — check the font's actual available weights, from Google Fonts or wherever it's sourced, rather than assuming every numeric value between 100 and 900 will render distinctly.

editor.html
h1 {
  font-weight: bold;
}

p {
  font-weight: normal;
}
localhost:3000

Examples

Example 01Basic Usage
h1 {
  font-weight: bold;
}

p {
  font-weight: normal;
}
Example 02Advanced Example
@font-face {
  font-family: 'CustomFont';
  src: url('custom-400.woff2');
  font-weight: 400;
}

.text {
  font-family: 'CustomFont';
  font-weight: 600;
}

Best Practices

  • Check which specific numeric weights a font family actually provides before relying on an in-between value like 500 or 600 to look visually distinct
  • Load only the specific font-weight values a design actually uses via @font-face or a font service like Google Fonts, rather than the entire available weight range, to reduce page load size
  • Use the bold keyword, or its equivalent 700, as the default choice for standard bold text, reserving finer-grained numeric weights for designs specifically calling for them

Interview Question

Why might setting font-weight: 500 on an element have no visible effect at all, rendering identically to font-weight: 400?

Hint: Think about what a font-weight value actually refers to — a genuinely distinct set of letterforms drawn specifically for that weight, or a mathematical scaling effect the browser applies automatically.

Each distinct font weight, like regular (400), medium (500), or bold (700), typically corresponds to an entirely separate font file containing letterforms specifically hand-designed and drawn at that particular thickness, rather than the browser mathematically thickening a single base font file to simulate different weights on demand. If a font family, whether a system font or one specifically loaded via @font-face or a font service, only actually provides font files for the 400 and 700 weights, requesting font-weight: 500 gives the browser no matching, specifically-designed font file to render, and its standard behavior in that situation is to fall back to the nearest weight it does have available, most commonly 400, rather than attempting to synthesize a genuinely new, distinct in-between appearance. This is exactly why simply specifying a numeric font-weight value doesn't guarantee a visually distinct result, that distinctness depends entirely on whether a font file for that specific weight was actually made available to the browser in the first place.

Exercises

MediumPractice using Font-weight in a real scenario.
View Solution
h1 {
  font-weight: bold;
}

p {
  font-weight: normal;
}

Frequently Asked Questions

Why might setting font-weight: 500 on an element have no visible effect at all, rendering identically to font-weight: 400?

Each distinct font weight, like regular (400), medium (500), or bold (700), typically corresponds to an entirely separate font file containing letterforms specifically hand-designed and drawn at that particular thickness, rather than the browser mathematically thickening a single base font file to simulate different weights on demand. If a font family, whether a system font or one specifically loaded via @font-face or a font service, only actually provides font files for the 400 and 700 weights, requesting font-weight: 500 gives the browser no matching, specifically-designed font file to render, and its standard behavior in that situation is to fall back to the nearest weight it does have available, most commonly 400, rather than attempting to synthesize a genuinely new, distinct in-between appearance. This is exactly why simply specifying a numeric font-weight value doesn't guarantee a visually distinct result, that distinctness depends entirely on whether a font file for that specific weight was actually made available to the browser in the first place.

Related Functions

Font-familyFont-styleFont-size