EthicsComputerCourses
Join training +91 90532 10052

Font Weight & Font Style

CSS · Lesson 31 of 240 Beginner 11 min read Updated

By the end of this lesson you will be able to make text thin, normal or heavy with font-weight, slant it with font-style, and predict what the browser does when a font does not have the weight or style you asked for. You will also know how to stop the browser from faking bold and italic letters, which matters a lot for Hindi and other Indian scripts.

You chose font families and sizes in Font Family & Font Size, and you saw the big picture of readable text in Typography Fundamentals. This lesson goes deeper into weight and style. Our running example is the weather page of a city newspaper.

What font-weight controls

Font weight is the thickness of the strokes that make up each letter. Think of writing the same word with a fine gel pen, a ballpoint and a thick marker. The letters are the same, but they feel lighter or heavier.

CSS describes weight with numbers. The common values are the hundreds from 100 to 900:

NumberCommon nameTypical use
100ThinVery large display text only
300LightLarge intro text, subtitles
400Regular (keyword normal)Body text
500MediumButtons, menu items
600Semi BoldSub-headings, labels
700Bold (keyword bold)Headings, important words
900BlackHuge headlines

The values 200 (Extra Light) and 800 (Extra Bold) sit in between. Modern CSS also accepts any number from 1 to 1000, such as font-weight: 650, but that only makes a visible difference with a variable font (more on that later).

CSS
h1 { font-weight: 800; }
.standfirst { font-weight: 300; }
p { font-weight: normal; }   /* same as 400 */

When the font does not have that weight

A normal font family ships a few separate files, called faces: perhaps Regular, Bold and Italic. If you ask for 300 and the family has no Light face, the browser picks the nearest face it has. For weights below 400 it looks for a lighter face first, then a heavier one. For weights above 500 it looks for a heavier face first, then a lighter one. So font-weight: 300 on a family with only Regular and Bold usually gives you Regular, and nothing seems to change.

This is why the same CSS can look different on two devices. Your laptop's font may have six weights, while a phone's font has only three.

bolder and lighter

The keywords bolder and lighter are relative: the result depends on the weight the parent element already has. The browser uses this table:

Parent's weightbolder giveslighter gives
below 100400no change
100 to 349400100
350 to 549700100
550 to 749900400
750 to 899900700
900 or moreno change700

The browser's own style sheet gives <strong> and <b> the value bolder. That explains a surprise beginners often meet: a <strong> inside a light 300 paragraph becomes 400, which looks almost normal. A <strong> inside a 600 heading becomes 900, which can look very heavy.

Step 1: a weight scale for the weather page

Let us give each part of the newspaper story its own weight. Run the example and look at each line.

HTMLOpen in editor
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Weather page weights</title>
  <style>
    body { font-family: system-ui, sans-serif; padding: 1rem; max-width: 40rem; color: #1f2933; }
    .kicker { font-weight: 600; color: #0b6e4f; }
    h1 { font-weight: 800; font-size: 2.2rem; margin: 0.2rem 0; }
    .standfirst { font-weight: 300; font-size: 1.25rem; }
    .byline { font-weight: 500; }
    .story { font-family: Georgia, "Times New Roman", serif; font-weight: 400; line-height: 1.6; }
    .scale span { margin-right: 0.5rem; }
  </style>
</head>
<body>
  <p class="kicker">Weather</p>
  <h1>Heavy rain likely in Pune till Sunday</h1>
  <p class="standfirst">The weather office has issued an orange alert. <strong>Schools may stay shut</strong> on Friday.</p>
  <p class="byline">By Meera Kulkarni</p>
  <p class="story">Low-lying areas near the river saw water on the roads by evening. Farmers in nearby villages said the rain came <strong>two weeks early</strong> this year.</p>
  <p class="scale">
    <span style="font-weight:100">100</span><span style="font-weight:300">300</span><span style="font-weight:400">400</span><span style="font-weight:500">500</span><span style="font-weight:600">600</span><span style="font-weight:700">700</span><span style="font-weight:900">900</span>
  </p>
</body>
</html>

The headline is heavy, the standfirst (the short summary under a headline) is light, and the body text is regular. Look at the two <strong> elements. Inside the light standfirst, "Schools may stay shut" is only a little darker, because bolder turned 300 into 400. Inside the regular story it becomes a clear 700.

On the last line, count how many different thicknesses you can really see. On a Windows laptop you may see five or six; on other devices only two or three, because several numbers fall back to the same face.

font-style: italic and oblique

font-style controls slant. It has three values:

  • normal: upright letters.
  • italic: a separately designed, slanted face. In many serif fonts the italic letters have different shapes. For example, the "a" often loses its top curve.
  • oblique: the upright letters, simply leaned to one side.

Think of the difference between joined-up handwriting and ordinary printed letters that you tilt. Italic is redrawn; oblique is tilted.

When you ask for oblique and the font has a true italic face, browsers usually use the italic face, so you will often see no difference at all. You can also give an angle, such as font-style: oblique 10deg. The angle works reliably only with a variable font that has a slant setting, so beginners rarely need it.

HTML already makes some elements italic: <em>, <i>, <cite>, <dfn>, <var> and <address>. You can switch that off with font-style: normal, for example on an <address> block in the newspaper footer.

CSS
figcaption cite { font-style: italic; }   /* photo credit */
address { font-style: normal; }           /* office address in the footer */

Faux bold and faux italic

What happens if you ask for bold or italic and the font has no such face at all? By default the browser fakes it. This is called synthesis. For fake bold it draws each letter with thicker strokes. For fake italic it slants the upright letters. Designers call the results faux bold and faux italic.

Fakes are fine in an emergency, but they have real problems:

  • Faux bold can look smudged and makes letters crowd each other.
  • Faux italic is just tilted, so it lacks the shapes a real italic has.
  • Many scripts have no tradition of italics at all. Most Devanagari, Tamil, Bengali, Chinese and Japanese fonts have no italic face, so a slanted version can look wrong to native readers.

The font-synthesis property controls this. Its values are none, or any of weight, style, small-caps and position. Listing a word allows that kind of fake; leaving it out forbids it. It has been supported in all major browsers since January 2022.

CSS
font-synthesis: none;          /* never fake anything */
font-synthesis: weight;        /* allow fake bold, forbid fake italic */

Step 2: protecting the Hindi edition

The newspaper also prints a Hindi edition. Emphasised Hindi words should not be slanted. Run this example and compare the two lines.

HTMLOpen in editor
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Hindi edition</title>
  <style>
    body { font-family: system-ui, sans-serif; padding: 1rem; font-size: 1.3rem; }
    .label { font-size: 0.9rem; color: #52606d; margin-bottom: 0; }
    .fixed[lang="hi"] { font-synthesis: weight; }
    .fixed[lang="hi"] em { color: #b42318; font-weight: 600; }
  </style>
</head>
<body>
  <p class="label">Default: the browser may fake an italic</p>
  <p lang="hi">पुणे में <em>भारी बारिश</em> की चेतावनी, <strong>स्कूल बंद</strong></p>
  <p class="label">Fixed: no fake italic, emphasis shown with colour and weight</p>
  <p lang="hi" class="fixed">पुणे में <em>भारी बारिश</em> की चेतावनी, <strong>स्कूल बंद</strong></p>
</body>
</html>

On most devices the first line shows "भारी बारिश" leaning to the right. Your Hindi font has no italic face, so the browser slanted the letters itself. In the second line, font-synthesis: weight forbids fake italic but still allows fake bold. The <em> still asks for italic, but the browser may no longer fake it, so the letters stay upright. A colour and a heavier weight keep the emphasis visible. The selector .fixed[lang="hi"] uses the attribute selector you met earlier.

If your device's Hindi font happens to include an italic, both lines will slant in the same, correct way. That is the browser using a real face, not a fake.

Variable fonts at beginner depth

A variable font is one font file that contains every weight in a range, not just a few fixed faces. With a variable font, font-weight: 550 or font-weight: 650 draws exactly that thickness, so you can fine-tune headings. Some variable fonts also have a slant or width setting.

Some operating system fonts are variable and many are not, so with system font stacks you cannot count on in-between values. When you start loading your own fonts, the @font-face rule describes the range a variable font covers. That is shown in Font Family & Font Size, and font sizing systems come later in Professional Typography Systems.

Common mistakes

  • Expecting every number to look different. If the font has no Light face, 300 looks the same as 400.
  • Using bolder and expecting 700. The result depends on the parent's weight, as the table shows.
  • Thin text for body copy. Weights of 100 to 300 are hard to read at small sizes, especially on cheap phone screens.
  • Italic for long passages. A full paragraph in italic is tiring. Keep it for short phrases, titles and captions.
  • Letting the browser slant Indian scripts. Turn off style synthesis for languages without italics and show emphasis another way.

Interview questions

1. What do the numbers in font-weight mean, and what are normal and bold?

They describe stroke thickness on a scale where 100 is thinnest and 900 is heaviest. normal equals 400 and bold equals 700. Modern CSS accepts any value from 1 to 1000, but only fonts that have matching faces, or variable fonts, will show the difference.

2. How is bolder calculated?

It is relative to the inherited weight, not a fixed value. A parent of 400 gives 700, a parent of 300 gives 400, and a parent of 600 gives 900. Because <strong> and <b> use bolder by default, their final weight depends on where they sit.

3. What is the difference between italic and oblique?

An italic face is a separately designed set of slanted letters, often with different shapes. Oblique is the upright design leaned at an angle. If a font has only an italic face, browsers normally use it for oblique too.

4. What is font synthesis and when would you turn it off?

When a requested bold or italic face is missing, the browser fakes it by thickening or slanting the normal letters. You turn it off with font-synthesis, for example for Devanagari, Chinese or Arabic text, where fake slanting or thickening can hurt legibility. You then show emphasis another way, such as colour or a real heavier weight.

5. Why might font-weight: 300 look identical to 400 on one device but not on another?

The browser can only use faces the font actually has. If the font on that device has no Light face, the matching rules choose the nearest available face, which is often Regular. A device with a richer font, or a variable font, shows a real 300.

Key points

  • font-weight runs from 100 to 900; normal is 400 and bold is 700.
  • If a weight is missing, the browser picks the nearest face, so some values look the same.
  • bolder and lighter depend on the parent's weight, and <strong> uses bolder by default.
  • italic uses a redesigned slanted face; oblique leans the upright letters.
  • Browsers fake missing bold and italic faces; font-synthesis lets you forbid that.
  • Turn off fake italic for scripts without italics, such as Devanagari, and emphasise with colour or weight.
  • Variable fonts draw any weight in their range, such as 650.

Exercise

Style the photo caption area of the weather page. Create a <figure> with a CSS-drawn grey box as the "photo" and a <figcaption> that contains a caption sentence and a photo credit in a <cite> element. Make the caption weight 400, the credit 600 and not italic, and add one <em> word in the caption. Then add a Hindi caption below with lang="hi" and make sure the browser never fakes an italic for it.

Show solution
HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Photo caption</title>
  <style>
    body { font-family: system-ui, sans-serif; padding: 1rem; }
    .photo { height: 10rem; background: #cbd2d9; border-radius: 0.5rem; }
    figcaption { font-weight: 400; color: #3e4c59; margin-top: 0.5rem; }
    figcaption cite { font-weight: 600; font-style: normal; }
    [lang="hi"] { font-synthesis: weight; }
    [lang="hi"] em { color: #b42318; }
  </style>
</head>
<body>
  <figure>
    <div class="photo"></div>
    <figcaption>Commuters wade through water near the station, <em>again</em>. <cite>Photo: Rohan Desai</cite></figcaption>
    <figcaption lang="hi">स्टेशन के पास पानी में चलते यात्री, <em>फिर से</em>।</figcaption>
  </figure>
</body>
</html>

The <cite> loses its default italic and gains weight instead. The Hindi caption forbids fake italic with font-synthesis: weight and shows emphasis with colour.

Quick Quiz

1. A paragraph has font-weight: 300. What weight does a <strong> inside it get by default?

2. You set font-weight: 300 but the text looks exactly like 400. What is the most likely reason?

3. What does font-synthesis: none do?

4. Which statement about italic and oblique is true?

Learn CSS with a mentor

Free lessons get you started. Our Full Stack Web Development training adds real projects and code reviews from working developers.

  • Project-based learning
  • Mentor code reviews
  • Free counselling call