Published Jun 29, 2021Updated Sep 21, 2023
Contribute to Docs

Specify the typeface in a rule set.


font-family: <font-family-name>;

Where <font-family-name> can be the following:

  • Roboto
  • "Open Sans"
  • or can be selected from Google Fonts that suites you.

If a font family name is not available, browsers will display their default font. When using a multi-word font name, wrap them in quotes.

Example 1

Set the h1 tag to Roboto:

h1 {
font-family: Roboto;

Example 2

Set the p tag to Roboto and Noto Sans:

p {
/* Font stack */
font-family: Roboto, 'Noto Sans';

If the primary font-family is not supported it will defer to the fallback font. Multiple fonts can be chained to create a font stack.

Note: To use multiple languages in the same tag, like ‘你好 World!’, the declared font may not be supported for the Chinese language. In that case, the Chinese text will be shown in the default font.

All contributors

Looking to contribute?

Learn CSS on Codecademy