Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

CSS font-size property


May 05, 2021 CSS Reference Manual


Table of contents


CSS font-size property


Set the font size of different HTML elements:

h1 {font-size:250%}
h2 {font-size:200%}
p {font-size:100%}

Try it out . . .

Description of property definition and use

Font-size properties set the font size.

Default: medium
Inherited: yes
Version: CSS1
JavaScript syntax: object.style.fontSize="larger"


Browser support

The numbers in the table support the first browser version number of the property.

Attributes
font-size 1.0 5.5 1.0 1.0 7.0

The property value

Value Describe
  • xx-small
  • x-small
  • small
  • medium
  • large
  • x-large
  • xx-large

Set the size of the font to different sizes, from xx-small to xx-large.

Default: medium.

smaller Set font-size to a smaller size than the parent element.
larger Set font-size to a larger size than the parent element.
length Set font-size to a fixed value.
% Set font-size to a percentage value based on the parent element.
inherit It is stipulated that the font size should be inherited from the parent element.


Related articles

CSS tutorial: CSS Font

CSS Reference Manual: Font Properties