Using CSS we can set the fonts to use for different pieces of text on a web page. The type of fonts that you use are important as it can affect how a website's visitors experience the website.
We use the font-family
CSS property to set what font to use for a piece of text. The values we give to the property is the names of font family to use.
Here are some examples of commonly used font families:
What fonts can you use?
Web browsers (Chrome, Firefox, Internet Explorer etc.) come with some of the most commonly used fonts installed with the web browser. These are called web safe fonts.
Using the font-family
CSS property you can specify "fallback" fonts to use if the first one is not available to use.
For example the following code will try and use the font "Lato" which is not a web safe font and will not be found by the browser. The browser will then try and use the fallback font "Courier New" instead.
You can specify multiple fallback fonts e.g. font-family: Lato, Tahoma, Verdana
We use the font-weight
CSS property to set the weight of the font. The values we can use for it are:
We use the font-size
CSS property to specify what size the font should appear. Normally we specify the font-size
in pixels.