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:
The example below shows the font-size
property in action.
Example
Try this code »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 |
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 |
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.
Basic Support—
|
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
.