Little Web Hut

CSS 2.1 Reference: font-size Property

CSS font-size Property
Syntax
selector {font-size: value;}
  • value is specified by using a length, percentage, or one of the following keywords: xx-small, x-small, small, medium, large, x-large, xx-large, larger, smaller or inherit.
Usage

The font-size property is used to specify the size of a font.

This property is specified by using a length, percentage, or keyword, according to the syntax shown above. Font sizes cannot be negative. If a percentage value is used, the value will be a percentage of the inherited font size. If a length value is used, the em and ex length values will be relative to the element's parent font-size property.


CSS Example: The font-size properties are set using a length, percentage, and numerous keywords.
  #tst1 {font-size: smaller;}
  #tst2 {font-size: larger;}
  #tst3 {font-size: 150%;}
  #tst4 {font-size: 20px;}
  #tst5 {font-size: xx-small;}
  #tst6 {font-size: x-small;}
  #tst7 {font-size: small;}
  #tst8 {font-size: medium;}
  #tst9 {font-size: large;}
  #tst10 {font-size: x-large;}
  #tst11 {font-size: xx-large;}
Test It HTML StyleTest It XHTML StyleTest It HTML5 Style

Keywords
  • xx-small - This is a font size sample.
  • x-small - This is a font size sample.
  • small - This is a font size sample.
  • medium - This is a font size sample.
  • large - This is a font size sample.
  • x-large - This is a font size sample.
  • xx-large - This is a font size sample.
  • larger - This font size is relative to the font size of the parent element.
  • smaller - This font size is relative to the font size of the parent element.
  • inherit - The inherit keyword is used to specify that the value for this property should be taken from the parent element. If inherit is used with the root element, then the initial value for this property will be used.
Applies To All elements
Inherited Yes
Initial Value medium


font-size Property Examples
Test It HTML StyleTest It HTML StyleTest It HTML5 StyleThe font-size properties are set using a length, percentage, and numerous keywords.