CSS font Property


This chapter teaches you how to set fonts of a content, available in an HTML element. You can set following font properties of an element −

  • The font-family property is used to change the face of a font.

  • The font-style property is used to make a font italic or oblique.

  • The font-variant property is used to create a small-caps effect.

  • The font-weight property is used to increase or decrease how bold or light a font appears.

  • The font-size property is used to increase or decrease the size of a font.

  • The font property is used as shorthand to specify a number of other font properties.

The font-size and font-family values are required. If one of the other values is missing, their default value are used.

Note: The line-height property sets the space between lines.

CSS Syntax

font: font-style font-variant font-weight font-size/line-height font-family|caption|icon|menu|message-box|small-caption|status-bar|initial|inherit;

Supported Browsers:

  • Firefox: 52.0, 2.0 -moz-
  • Google Chrome: 50.0, 4.0 -webkit-
  • Internet Explorer: 10.0
  • Safari: 9.0, 3.1 -webkit-
  • Opera: 37.0, 15.0 -webkit-, 11.1

Example -