The CSS font-size property sets the font size of an html element.
CSS property font-size
CSS version: | CSS 2.1 |
Value: | absolute-size | relative-size | length | percentage | inherit |
Initial: | medium |
Applies to: | all elements |
Inherited: | yes |
font-size values
absolute-size | Possible values are xx-small, x-small, small, medium, large, x-large, xx-large |
relative-size | larger/smaller. It is relative to the parent element font size. |
length | 14px, 16px, etc |
peecentage | percentage of parent element font size. |
Example – font-size
In the following code, CSS property font-size can be changed to the following values
- xx-small
- x-small
- small
- medium
- large
- x-large
- xx-large
- larger
- smaller
- 14px
- 80%
- 120%
<style type="text/css"> div { width: 100px; background-color: lightblue; font-size: xx-small; } </style> <div>This is sample text to test font-size property</div> Text outside div
font-size refresh