CSS property: font-size

Description

This property indicates the desired height of glyphs from the font.

For scalable fonts, the font-size is a scale factor applied to the EM unit of the font. (Note that certain glyphs may bleed outside their EM box.) For non-scalable fonts, the font-size is converted into absolute units and matched against the declared font-size of the font, using the same absolute coordinate space for both of the matched values.

Syntax

font-size: <absolute-size> | <relative-size> | <length> | <percentage>;

Values

<absolute-size>

An <absolute-size> keyword refers to an entry in a table of font sizes computed and kept by the user agent.

xx-small
x-small
small
medium (by default)
large
x-large
xx-large
<relative-size>

A <relative-size> keyword is interpreted relative to the table of font sizes and the font size of the parent element.

larger
smaller
<length>

A length value specifies an absolute font size (that is independent of the user agent's font table). Negative lengths are illegal.

<percentage>

A percentage value specifies an absolute font size relative to the parent element's font size. Use of percentage values, or values in ems, leads to more robust and cascadable style sheets.

Versions

Examples

h1 {
    font-size: 2em;
}
p {
    font-size: 90%;
}
li li {
    font-size: smaller;
}