font-family

Specify the typeface in a rule set.

Syntax

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, it is best practice to wrap them in quotes.

Example 1

Set the p tag to Roboto:

p {
font-family: Roboto;
}

Example 2

Set the h1 tag to "Open Sans":

h1 {
font-family: 'Open Sans';
}
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