GeoffKnagge.com

Font properties

PLEASE NOTE: This section only describes the font properties that are most likely to be required. For information about the advanced @font-face rule for specifying fonts, see the W3C CSS2 specification and look under "fonts".

font

Value[ font-style || font-variant || font-weight ] font-size [ / line-height ] font-family | caption | icon | menu | message-box | small-caption | status-bar | inherit
Used Withall elements
InheritedYes
ExampleP { font: 12pt/14pt sans-serif }
caption, icon, menu, message-box, small-caption, status-bar refer to the fonts used for the respective items within the viewing program.

For all of the other value types, see the individual properties below.

font-family

Valuecomma seperated list in priority order, containing either a family-name or a generic-family | inherit
Used Withall elements
InheritedYes
example BODY { font-family: "Times New Roman", serif }
  • Font names containing spaces must be quoted, otherwise only the first word is used
  • Values can be one of two types :
    • family-name : The name of a font which may be installed, such as Times New Roman.
    • generic-family : one of serif, sans-serif, cursive, fantasy, monospace. One of these should be offered as the last alternative.

font-style

Valuenormal | italic | oblique | inherit
Initialnormal
Used Withall elements
InheritedYes
example BODY { font-style: italic }

font-variant

Valuenormal | small-caps | inherit
Initialnormal
Used Withall elements
InheritedYes
example BODY { font-variant: small-caps }

font-weight

Valuenormal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit
Initialnormal
Used Withall elements
InheritedYes
example BODY { font-weight: 900 }

Normal and 400 are the same, as are bold and 700. The bolder and lighter are values relative to whatever the inherited value would have been.

font-size

Value absolute-size | relative-size | length | percentage | inherit
Initialmedium
Used Withall elements
InheritedYes
Percentage Valuesrelative to parent element's font size
absolute-size is one of xx-small, x-small, small, medium, large, x-large, or xx-large.

relative-size is larger or smaller and represents an absolute-size, relative to what is inherited.

length is a positive number with the units em, ex or pt. Values are relative to what would have been inherited, but on other properties it refers to the font-size of the current element.

Examples:
  P { font-size: 12pt; }
  P { font-size: larger }
  P { font-size: 150% }
  P { font-size: 1.5em }

font-size-adjust

Value number | none | inherit
Initialnone
Used Withall elements
InheritedYes
Percentage Valuesrelative to parent element's font size
This property is used to specify an aspect value for the font in order to preserve the x-height of the first choice font, if it is not available. The value specifies the aspect value of the first choice font.

font-stretch

Valuenormal | wider | narrower | ultra-condensed | extra-condensed | condensed | semi-condensed | ultra-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit
Initialnormal
Used Withall elements
InheritedYes
ExampleH1 { font-stretch: semi-condensed }
This specifies a relative or an absolute value for the width of the font. The values above are listed in order from narrowest to widest .
(C)opyright, Geoff Knagge.
Continued use of this site indicates your agreement to the Conditions of use and Privacy Policy.