Skip to content
Justice Tech School

Fonts

font-family sets the typeface. Always list fallbacks and end with a generic family such as sans-serif, serif or monospace. font-size sets size, font-weight sets boldness (400 normal, 700 bold) and font-style: italic slants text.

Fonts that are not installed on the reader's device will not appear, so the fallback list matters. The font shorthand packs several of these into one line.

Example
<style>
  p { font-family: Georgia, "Times New Roman", serif; font-size: 20px; }
  .bold { font-weight: 700; }
  .italic { font-style: italic; }
  code { font-family: ui-monospace, Consolas, monospace; }
</style>
<p>Regular serif text</p>
<p class="bold">Bold text</p>
<p class="italic">Italic text</p>
<p><code>monospace code</code></p>

Exercise

Make the text bold.

h2 {
  font-: bold;
}

Quiz Test

Why list a generic family like sans-serif last?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.