Loading…
Everything will be ready in few seconds
- Theory
- Theory
- Comments
The font-family property
We have already figured out how to set the font size, but how do we set the font itself?
We have a special property for this: font-family
. A comma-separated list of font names is specified as the value of this property. We write our most preferred font at the beginning of the list followed by alternative fonts in order of preference. Include a general font family at the end of the list. The browser processes the list from left to right and uses the first font that is installed on the system or website. Example:
body {
font-family: "PT Sans", "Arial", sans-serif;
}
If the name of the font consists of several words, then it must be enclosed in quotes. Single names can be written either without quotes or with them for consistency. If the browser does not find any of the listed font names installed on the website or in the operating system, then it will use the last value — the general system font family. The most common font families are:
serif
— A font with lines (serifs) at the end of some letters;sans-serif
— A font that lacks these serifs.
In fact, there are also less commonly used font families besides serif
and sans-serif
:
monospace
— A font where with even spaces between characters;cursive
– An informal typeface, including, for example, ones that imitate handwriting or calligraphy;fantasy
— A decorative font face, such as the world-famous Comic Sans.
- index.html
- style.css
Thanks! We’ll fix everything at once!
The code has changed, click “Refresh” or turn autorun on.
You’ve gone to a different page
Click inside the mini-browser to shift the focus onto this window.
Comments