HTML Font Size Code

In HTML, font size is specified using CSS (Cascading Style Sheets). Font size is specified using the font-size property.

The actual value of the font-size property can be specified in different ways. You can specify font size in any of the following ways:

Option 1: Absolute Size

Absolute size refers to an entry in a table of font sizes that is calculated, and kept by the browser (or other user agent). Because of this, the text will always be displayed at the same size regardless of its surrounding elements. This is because the sizes are pre-calculated by the browser/user agent.

Here's an example of setting font size using absolute sizes:

Option 2: Relative Size

Relative size allows you to set the font size relative to the parent element. This means that different text with the same (relative) value could actually appear in many different sizes - even on the same page. It all depends on the text's parent element. There are two possible values: 'smaller' and 'larger'.

Option 3: Length Value

A length value allows you to specify an absolute font size, regardless of the surrounding elements. There are eight possible values.

Relative Values:

Absolute Values:

Examples of Relative Values

Examples of Absolute Values

Option 4: Percentage Values

Percentage values specify an absolute font size relative to the parent element's font size.

More Font Properties

Here are more CSS font properties you can use on your text: