#font-size

Defines the size of the text.

默认属性 font-size: medium;

The text will use the browser's default medium size.

font-size: 20px;

You can use pixel values.

font-size: 1.2em;

You can use em values.

The value is relative to the parent's font-size.
As a result, the value will cascade if used on child elements.

font-size: 1.2rem;

You can use rem values.

The value is relative to the root element's font-size, which is the <html> element.
As a result, the value will not vary depending on the depth of the element in the HTML hierarchy, and will reamin context independent.

font-size: 90%;

You can use percentage values. They act like em values.

The value is relative to the parent's font-size.
As a result, the value will cascade if used on child elements.

font-size: smaller;

You can use relative keywords. The value is relative to the parent.

The following are available:

  • larger
  • smaller

font-size: x-large;

You can use absolute keywords. The value is relative to the root element <html>.

The following are available:

  • xx-small
  • x-small
  • small
  • medium
  • large
  • x-large
  • xx-large