CSS font-family property
Browser support · legacy reference
ChromeFully supports
SafariFully supports
FirefoxFully supports
Internet ExplorerFully supports
EdgeFully supports
OperaFully supports
Description
CSS font-family property defines the types of font faces that vary in size and shapes.
There are only five generic families such as serif, sans-serif, cursive, fantasy, and monospace. But each generic family has many other families (family-name).
Syntax
font-family : list of family-names, generic-family
Property values
generic-family
serifDefault
-
The fonts that proportionaly-spaced and have thick or thin strokes than fonts.
- Try it
font-family: serif; sans-serif
-
sans-serif means without sharp strokes. The fonts that have plain stroke endings i.e. there are sharp or cross strokes.
- Try it
font-family: sans-serif; cursive
-
They are not formal type fonts. They look as if they have been written by a brush or hand.
- Try it
font-family: cursive; fantasy
-
fantasy fonts are more decorative and contain expressive representation of characters.
- Try it
font-family: fantasy; monospace
-
It looks like computer code. It represents text as if typed by a keyboard.
- Try it
font-family: monospace; list of families
-
We may use comma separated list of family names. This list should end up with a generic-family.
And if one family is not rendered by the browser, the next one will be used. If all the families are not rendered by browser, the generic-family must be used.
- Try it
font-family: courier, monospace;
Applicable to
It applies to all elements