CSS font-size

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-sizePossible values are xx-small, x-small, small, medium, large, x-large, xx-large
relative-sizelarger/smaller. It is relative to the parent element font size.
length 14px, 16px, etc
peecentagepercentage 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

Related

Specification

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments