CSS Fonts

1. Font Family

The font-family property is used to specify the font of the text. It’s always a good idea to define multiple fonts as backups. If the browser can’t load your first choice, it will try the next ones on the list.

CSS

Here, the browser will first try to apply Arial. If it’s not available, it will try Helvetica, and if that’s also unavailable, it will use a generic sans-serif font.

Tutorials dojo strip


2. Font Size

To change the size of your text, use the font-size property. You can define the size in different units like px (pixels), em, rem, or % depending on whether you want a fixed size or one that scales with the rest of the page.

CSS
  • Pixels (px) give a fixed size.
  • Relative units like em and rem allow your text to scale, making your design more flexible.


3. Font Weight

The font-weight property controls how bold or light the text appears. You can specify it using keywords like normal, bold, or by numbers ranging from 100 to 900.

CSS


4. Font Style

If you want to italicize your text, use the font-style property.

CSS




CSS Fonts Example Code

HTML/CSS




CSS Labs

Tutorials dojo strip