font-size

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

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;
}
Edit this page on GitHub

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn CSS on Codecademy

Edit this page on GitHub

Contributors