Currently Empty: ₹0.00
CSS Fonts
CSS CODES & EXAMPLES
CSS Fonts
Learn how to control text appearance using CSS font properties such as font-family, font-size, font-weight, font-style and line-height.
01
What are CSS Fonts?
Control the appearance of textCSS provides several properties for controlling how text is displayed. These properties allow you to select a font, change its size, make it bold or italic, adjust spacing and create readable layouts.
Remember:
Fonts affect readability, visual hierarchy and the overall
design of a website.
02
Basic Font Properties
Important properties to learnfont-familySpecifies the typeface.
font-sizeControls the size of text.
font-weightControls text thickness.
font-styleControls normal, italic or oblique text.
line-heightControls vertical space between lines.
fontShorthand for several font properties.
03
font-family
Choose a typeface
The font-family property specifies the font used
to display text.
font-family.css
body {
font-family: Arial, sans-serif;
}
Arial Font Example
Georgia Font Example
Courier New Font Example
04
font-size
Change text size
The font-size property controls the size of text.
Common units include px, em,
rem and percentages.
font-size.css
.small {
font-size: 14px;
}
.medium {
font-size: 20px;
}
.large {
font-size: 32px;
}14px Text
20px Text
32px Text
05
font-weight
Control text thickness
The font-weight property controls how thick or
light the characters appear.
font-weight.css
.normal {
font-weight: 400;
}
.medium {
font-weight: 500;
}
.bold {
font-weight: 700;
}
.heavy {
font-weight: 900;
}
Weight 400
Weight 500
Weight 700
Weight 900
06
font-style
Normal and italic text
The font-style property is commonly used to
display normal, italic or oblique text.
font-style.css
.normal {
font-style: normal;
}
.italic {
font-style: italic;
}
.oblique {
font-style: oblique;
}
Normal Text
Italic Text
Oblique Text
07
line-height
Improve text readability
The line-height property controls the vertical
distance between lines of text. It is especially important for
paragraphs and long-form content.
line-height.css
p {
font-size: 16px;
line-height: 1.7;
}
Good Line Height
CSS line-height makes paragraphs easier to read. Proper spacing between lines creates a cleaner and more comfortable reading experience.
08
Font Shorthand
Write multiple font properties together
The font property can combine several font
properties into one declaration.
font-shorthand.css
.text {
font: italic 700 20px/1.6 Arial, sans-serif;
}Structure:
font-style →
font-weight →
font-size/line-height →
font-family
09
System Font Stack
Use fonts available on the user’s device
system-font.css
body {
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
sans-serif;
}A font stack provides fallback choices so the browser can use an available font when the first choice is not installed.
10
Google Fonts Example
Using an external web fontWeb fonts can be loaded from external font services. For example, a website can use the Poppins family.
google-font.css
<link
href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap"
rel="stylesheet">
body {
font-family: "Poppins", sans-serif;
}
Poppins Font Example
11
Font Color and Typography
Combine fonts with text styling
typography.css
.heading {
font-family: Arial, sans-serif;
font-size: 34px;
font-weight: 700;
line-height: 1.2;
color: #1769d5;
}
.description {
font-size: 16px;
line-height: 1.7;
color: #607084;
}Learn Computer Skills
Build practical digital skills through structured lessons, examples and hands-on practice.
12
Responsive Font Size
Use modern responsive typography
responsive-font.css
h1 {
font-size: clamp(28px, 5vw, 52px);
}
Responsive Heading
clamp() can create a font size that grows with the
viewport while staying within a minimum and maximum size.
13
Important Points
Quick revision
✓
font-family selects the typeface.
✓
font-size controls the size of text.
✓
font-weight controls thickness.
✓
font-style controls italic and related styles.
✓
line-height controls vertical text spacing.
✓
font can combine multiple font properties.
14
Practice Task
Create a professional course heading🎯 Your Challenge
Create a course title and paragraph using CSS typography.
- Use a suitable
font-family. - Set the heading to at least
32px. - Use
font-weight: 700. - Set paragraph
line-height: 1.7. - Make the heading responsive using
clamp().
15
CSS Fonts Live Runner
Run and experiment with typography
LIVE PREVIEW



