CSS PROPERTIES
Expand All | Collapse All
CSS AT-RULES

CSS font-size Property

Topic: CSS3 Properties ReferencePrev|Next

Description

The font-size CSS property sets the font size for the element's text content.

The following table summarizes the usages context and the version history of this property.

Default value: medium
Applies to: All elements
Inherited: Yes
Animatable: Yes. See animatable properties.
Version: CSS 1, 2, 3

Syntax

The syntax of the property is given with:

font-size: 
xx-small | x-small | small | medium | large | x-large | xx-large | smaller | larger | length | percentage | initial | inherit

The example below shows the font-size property in action.

body {
    font-size: 14px;
}
h1 {
    font-size: 2em;  
}

Property Values

The following table describes the values of this property.

Value Description
xx-small

A set of absolute size keywords. These keywords scale the font size of text according to the user's browser font setting preferences, and the browser's internal font scaling algorithms.

The medium value (16px) of the font-size property matches the user's browser default font size.

x-small
small
medium
large
x-large
xx-large
smaller

Smaller or larger or than the parent element's font size, by roughly the ratio used to separate the absolute size keywords above.

For example, if the parent element has a font size of medium, a value of larger will make the font size of the current element is large.

larger
length A length value in px, pt, cm, em, etc. Negative values are not allowed.
percentage Sets the font size to a percent of the parent element's font size. Negative values are not allowed.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element font-size property.

Note: The default value for the font-size property is medium (16px) in all modern browsers like Firefox, Chrome, IE, Safari, Opera etc.


Browser Compatibility

The font-size property is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 4+
  • Apple Safari 1+
  • Opera 4+

Further Reading

See tutorial on: CSS Fonts, CSS Text.

Related properties and at-rules: line-height, font, font-family, font-style, font-variant, font-weight, @font-face.

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties