CSS font-size

christian.dinh's avatar
Published Jun 29, 2021Updated Sep 3, 2021
Contribute to Docs

The font-size property sets text size. Font size values can be in many different units like absolute lengths and relative lengths.

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • In this CSS tutorial, you’ll learn how to add CSS to visually transform HTML into eye-catching sites.
    • Beginner Friendly.
      6 hours

Syntax

font-size: <font-size-value>;

Absolute lengths can be the following:

  • px
  • in
  • mm
  • cm
  • pt
  • pc

Relative lengths can be the following:

  • %
  • em
  • rem
  • ch
  • ex
  • vh
  • vw
  • vmax
  • vmin

Example 1

Set the p tag to 16px:

p {
font-size: 16px;
}

Example 2

Set the p tag to 2em:

html {
font-size: 16px;
}
p {
font-size: 2em;
}

All contributors

Contribute to Docs

Learn CSS on Codecademy

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • In this CSS tutorial, you’ll learn how to add CSS to visually transform HTML into eye-catching sites.
    • Beginner Friendly.
      6 hours