font-size

Introduction

font-size CSS property sets the size of the font. Changing the font size also updates the sizes of the font size-relative <length> units, such as em, ex, and so forth.

Examples

Syntax

/* <length> */
font-size: 12px;
font-size: 0.8em;

/* <percentage> */
font-size: 80%;

Values

  • <length>
    Positive <length> value. For most font-relative units (such as em and ex), the font size is relative to the parent element's font size.

  • <percentage>
    A positive <percentage> value, relative to the parent element's font size.

Formal definition

Initial value14px
Applies totext
Inheritedyes
Animatableno

Formal syntax

font-size = <length> | <percentage>

Difference with Web

  • Only support <length> and <percentage>

  • Default font-size is 14px not medium.

Compatibility

LCD tables only load in the browser

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.