04. Applying Fonts font-family, font-size

After we have chosen which font to use, and loaded them up using the @font-face property, we can now apply them to our webpage.

Applying fonts to text

To specify the text, we use the font-family property.

In case the user does not have a certain font, we list multiple, each separated by a comma. This list is called the font stack.

The user's browser then goes through each font, from left to right, searching for a font that works until it finds one.

p {
  font-family: Consolas, Arial, Helvetica, Serif, "Times New Roman";
}

Notice how we have to use quotation marks ("") when specifying a font that is longer than one word.

There are a few "safe" fonts such as Arial, Verdana and Times New Roman that are guaranteed to work.

Build modern and responsive webpages

Responsive Typography

Build modern and responsive webpages Try Front-end

Responsive web design helps your site maintain its design integrity on a variety of screen sizes, but how does it affect your typography? With this practical book, graphic designers, web designers, and front-end developers alike will learn the nuts and bolts of how to get the best appearance from type without sacrificing performance on any device.

$ Check price
24.9924.99Amazon 4.5 logo(3+ reviews)

More Front-end resources

Aching back from coding all day?

Self-Massage Tool

Aching back from coding all day? Try Back Problems

Relieve spasms, tight muscles, trigger points and pressure points with the Body Back Buddy! This trigger point massage is designed to help you self-message any area of your body - especially those that are hard to reach. Keeping your muscles relaxes and out of contraction is importan in helping to reduce pain and prevent muscle injury.

$ Check price
29.9529.95Amazon 4.5 logo(3,443+ reviews)

More Back Problems resources

Ad