Skip to content

CSS Tutorial CSS Fonts

CSS Font Family

Lesson 50 of 182 2 min read By Deepak Paswan Updated Oct 4, 2026

font-family chooses the typeface. You give it a list, in order of preference. The browser uses the first one that is available on the visitor’s device.

index.html
HTML
<style>
  .a { font-family: Georgia, "Times New Roman", serif; }
  .b { font-family: Arial, Helvetica, sans-serif; }
  .c { font-family: "Courier New", monospace; }
  p { font-size: 20px; margin: 6px 0; }
</style>
<p class="a">Georgia, with serif fallbacks.</p>
<p class="b">Arial, with sans-serif fallbacks.</p>
<p class="c">Courier New, with monospace fallback.</p>

The parts of a font stack

  • A specific font name, such as Georgia.
  • A list of backups in case it is missing.
  • A generic family as the last entry: serif, sans-serif, monospace, cursive or system-ui. The browser always has one of these.

Font names with spaces go in quotes: "Times New Roman".

Generic families at a glance

FamilyLookTypical use
serifSmall strokes at the ends of lettersBooks, editorial text
sans-serifClean, no strokesWebsites, interfaces
monospaceEvery letter the same widthCode
system-uiThe operating system’s own fontApp-like pages
lightbulb
Set it once on body
Put your main font-family on body. Everything inside inherits it. Note that form controls do not, by default. See Styling Inputs and Labels.

Next: which fonts you can safely count on: Web Safe Fonts.