View video tutorial
CSS Font-Size
CSS
This property is used to specify the height and size of the font.
CSS font-size
➔ The font-size property in CSS is used to set the height and size of the font.
Syntax
font-size:medium|xx-small|x-small|small|large|x-large|xx-large|smaller|larger|length|initial|inherit;
Property values
| Value | Description |
|---|---|
| medium | Sets the font-size to medium. This is default. |
| xx-small | Sets the font-size to xx-small. |
| x-small | Sets the font-size to x-small. |
| small | Sets the font-size to small. |
| large | Sets the font-size to large. |
| x-large | Sets the font-size to x-large. |
| xx-large | Sets the font-size to xx-large. |
| smaller | Sets the font-size to smaller. |
| larger | Sets the font-size to larger. |
| length | Sets the font-size to a specific size in px, cm, etc. |
| percent | Sets the font-size to a percentage of the parent element's font size. |
| initial | Sets the property to its default value. |
| inherit | The element inherits the property value from its parent element. |
Click on the "Try it Now" button to see how it works.
Example
body {
font-size: 100%;
}
#p1 {
font-size: 2.5em;
}
#p2 {
font-size: 1.875em;
}
#p3 {
font-size: 0.875em;
}
Click on the "Try it Now" button to see how it works.