agyanadda@gmail.com

CSS Fonts

Styling Elements 1 min read Updated Dec 1, 2026 Topic 12 of 39

Font properties

  • font-family — the typeface, with fallbacks: Arial, Helvetica, sans-serif
  • font-size — 16px, 1.2rem
  • font-weight — normal, bold, or 100–900
  • font-style — normal, italic

Generic families

Always end the list with a generic family: serif, sans-serif, monospace. The browser uses it if other fonts are missing.

Google Fonts

Add a font link in the <head>, then use the font name:

<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap" rel="stylesheet">

font-family: 'Poppins', sans-serif;

Shorthand

font: italic bold 18px/1.5 Arial, sans-serif;

Example

Example — Font families and weights HTML
<style>
  .serif { font-family: Georgia, serif; }
  .sans { font-family: Arial, sans-serif; }
  .mono { font-family: 'Courier New', monospace; }
  .bold { font-weight: 700; }
  .italic { font-style: italic; }
  p { font-size: 1.2rem; }
</style>

<p class="serif">Serif font (Georgia)</p>
<p class="sans">Sans-serif font (Arial)</p>
<p class="mono">Monospace font</p>
<p class="sans bold">Bold text</p>
<p class="sans italic">Italic text</p>

Test Yourself With Exercises

Exercise 1 Multiple Choice

Which property makes text bold?

Exercise 2 True / False

You should end a font-family list with a generic family like sans-serif.

Exercise 3 Fill in the Blank

font-style: ___; slants the text.

Frequently Asked Questions

Font names with spaces, like 'Courier New', should be in quotes.