Master CSS From Scratch

Clear, interactive, and structured CSS lessons designed for beginners.

Font Family

The font-family property is used to specify the typeface used for text on a web page.

You can specify one font family or provide multiple fallback fonts in case the preferred font is not available.

How Font Family Works

HTML Text
→
font-family
→
Selected Font

Example 1: Arial Font

The Arial font can be applied using the font-family property.

CSS Code
h2 {
    font-family: Arial;
}
Output

Welcome to CIIT Training Institute

Example 2: Georgia Font

The Georgia font gives text a serif-style appearance.

CSS Code
p {
    font-family: Georgia;
}
Output

Learn CSS at CIIT Training Institute.

Example 3: Multiple Font Families

Multiple fonts can be specified as fallback options. The browser uses the first available font.

CSS Code
p {
    font-family: Arial, Helvetica, sans-serif;
}
Output

CIIT Training Institute - Learn. Practice. Grow.

Example 4: Sans-Serif Font

A generic font family such as sans-serif can be used as a final fallback.

CSS Code
p {
    font-family: sans-serif;
}
Output

Welcome to CIIT Training Institute

Common Font Families

Font Family Type
Arial Sans-serif
Georgia Serif
"Times New Roman" Serif
Verdana Sans-serif
sans-serif Generic sans-serif family
serif Generic serif family

Simple Explanation

font-family: Arial; → Uses Arial for the text.

font-family: Georgia; → Uses Georgia for the text.

Arial, Helvetica, sans-serif → Provides fallback font choices.

The browser uses the first available font from the specified list.

Summary

The font-family property specifies the typeface used for text. You can define a single font or provide multiple fallback fonts to ensure consistent text rendering.