CSS font-size Property
Example
Set the font size for different elements:
div.a {
font-size: 15px;
}
div.b {
font-size: large;
}
div.c {
font-size: 150%;
}
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 | Demo |
---|---|---|
medium | Sets the font-size to a medium size. This is default | Demo ❯ |
xx-small | Sets the font-size to an xx-small size | Demo ❯ |
x-small | Sets the font-size to an extra small size | Demo ❯ |
small | Sets the font-size to a small size | Demo ❯ |
large | Sets the font-size to a large size | Demo ❯ |
x-large | Sets the font-size to an extra large size | Demo ❯ |
xx-large | Sets the font-size to an xx-large size | Demo ❯ |
smaller | Sets the font-size to a smaller size than the parent element | Demo ❯ |
larger | Sets the font-size to a larger size than the parent element | Demo ❯ |
length | Sets the font-size to a fixed size in px, cm, etc. Read about length units | Demo ❯ |
% | Sets the font-size to a percent of the parent element's font size | Demo ❯ |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Related Pages
CSS tutorial: CSS Fonts
CSS reference: font property
HTML DOM reference: fontSize property