CSS font-size Property

❮ Previous Reference Next ❯

Example

.a {
  font-size: 10px;
}

.b {
  font-size: small;
}

.c {
  font-size: 200%;
}





Hello World!


Meaning

The font-size property sets the font size of text.

Default value:medium
Inherited:Yes
Animatable:Yes
Version:CSS1
JavaScript syntax:
object.style.fontSize="medium|xx-small|x-small|small|large|x-large|xx-large|smaller|larger|length|%(percentage)|initial|inherit|revert|revert-layer|unset";



Standard Syntax

font-size: medium|xx-small|x-small|small|large|x-large|xx-large|smaller|larger|length|%(percentage)|initial|inherit|revert|revert-layer|unset;



Browser Support

The numbers in the table specify the first browser version that fully supports the property.




Status







Property Values

The following table describes the values of this property.

Value Description Demo
medium This is the default value. Specifies that the font-size to a medium size.

Hello World!

xx-small Specifies that the font-size to an xx-small size.

Hello World!

x-small Specifies that the font-size to an extra small size.

Hello World!

small Specifies the font-size to a small size.

Hello World!

large Specifies that the font-size to a large size.

Hello World!

x-large Specifies that the font-size to an extra large size.

Hello World!

xx-large Specifies that the font-size to an xx-large size.

Hello World!

smaller Specifies that the font-size to a smaller size than the parent element.

Hello World!

larger Specifies that the font-size to a larger size than the parent element.

Hello World!

length Specifies that the font-size to a fixed size in px, cm, etc.

Hello World!(24px)

%(percentage) Specifies that the font-size to a percent of the parent element's font size.

Hello World!(100%)

initial Sets this property to its default value.

Hello World!

inherit If specified, the associated element takes the computed value of its parent element animation-delay property.

Hello World!

revert Reverts the cascaded value of the property from its current value to the value the property

Hello World!

revert-layer Rollback styles to the ones specified in previous cascade layers.

Hello World!

unset Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not.

Hello World!




Default CSS Property Values

selectors {
  font-size: medium;
}
❮ Previous Reference Next ❯