CSS font-size Property


Example

Set the font size for different HTML elements:

h1 {
    font-size: 250%;
}

h2 {
    font-size: 200%;
}

p {
    font-size: 100%;
}

Try it yourself »

Definition and Usage

The font-size property sets the size of a font.

Default value: medium
Inherited: yes
Animatable: yes. Read about animatable Try it
Version: CSS1
JavaScript syntax: object.style.fontSize="14px" Try it


Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Property
font-size 1.0 5.5 1.0 1.0 7.0


CSS Syntax

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

Property Values

Value Description Play it
medium Sets the font-size to a medium size. This is default Play it »
xx-small Sets the font-size to an xx-small size Play it »
x-small Sets the font-size to an extra small size Play it »
small Sets the font-size to a small size Play it »
large Sets the font-size to a large size Play it »
x-large Sets the font-size to an extra large size Play it »
xx-large Sets the font-size to an xx-large size Play it »
smaller Sets the font-size to a smaller size than the parent element Play it »
larger Sets the font-size to a larger size than the parent element Play it »
length Sets the font-size to a fixed size in px, cm, etc. Play it »
% Sets the font-size to a percent of  the parent element's font size Play it »
initial Sets this property to its default value. Read about initial Play it »
inherit Inherits this property from its parent element. Read about inherit


Related Pages

CSS tutorial: CSS Font

CSS reference: font property

HTML DOM reference: fontSize property



Color Picker

colorpicker