Font Weight
Part of the Styling with CSS section of Coddy's HTML journey — lesson 20 of 76.
In CSS, the font-weight property is used to control the boldness or thickness of text within an HTML element.
Common numeric values for font-weight include:
100: Thin200: Extra Light300: Light
400: Normal500: Medium600: Semi Bold
700: Bold800: Extra Bold900: Black
Common keyword values for font-weight include:
normal: Equivalent to400bold: Equivalent to700
lighter: Specifies a lighter weight than the parent elementbolder: Specifies a bolder weight than the parent element
For example:
p {
font-weight: normal;
}
h1 {
font-weight: 700;
}
.highlight {
font-weight: bold;
}Challenge
EasyYou are given an HTML document with a heading (<h1>), a paragraph (<p>), and a division (<div>). Your task is to use the font-weight property to style these elements. Follow the steps below:
- Write a CSS rule that targets the
<h1>element. Set thefont-weightto900. - Write a CSS rule that targets the
<p>element. Set thefont-weighttolighter. - Write a CSS rule that targets the
<div>element. Set thefont-weightto600.
Cheat sheet
The font-weight property controls the boldness or thickness of text.
Numeric values:
100: Thin200: Extra Light300: Light400: Normal500: Medium600: Semi Bold700: Bold800: Extra Bold900: Black
Keyword values:
normal: Equivalent to400bold: Equivalent to700lighter: Lighter weight than parent elementbolder: Bolder weight than parent element
p {
font-weight: normal;
}
h1 {
font-weight: 700;
}
.highlight {
font-weight: bold;
}Try it yourself
<html>
<head>
<title>Font Weight</title>
<style>
/* Write CSS rules here */
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<div>This is a division.</div>
</body>
</html>This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Styling with CSS
4Text Fundamentals
Text ColorFont FamilyFont SizeFont WeightText AlignmentText DecorationRecap Challenge #1Recap Challenge #25 Colors and Backgrounds
Background ColorHEX ColorsRGB ColorsTransparency with RGBARecap Challenge #1