size (HTML attribute)

Spec
Depr. Version
Yes HTML 2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

size="number"

Description

The size attribute is used to bump the font size of text contained inside the font element up or down, or to a predefined size. The old font sizes provided with earlier HTML versions ranged from 1 to 7, with font size 3 being the browser default. It is possible to set a size up or down by using the + or - character, as shown in the examples below.

Example

The first set of examples below show the seven font sizes available (with the default font size alongside each by way of comparison):

<p>Default font size <font size="1">Font size 1</font></p>
<p>Default font size <font size="2">Font size 2</font></p>
<p>Default font size <font size="3">Font size 3</font></p>
<p>Default font size <font size="4">Font size 4</font></p>
<p>Default font size <font size="5">Font size 5</font></p>
<p>Default font size <font size="6">Font size 6</font></p>
<p>Default font size <font size="7">Font size 7</font></p>

And here’s how this looks:

Example of seven font sizes

To increase or decrease text sizes by increments, you could use the following:

<p>This is normal font and <font size="+2">this is two sizes
up</font>. This, on the other hand, is <font size="-2">two sizes
down</font>.</p>

And the effect can be seen as shown below:

Example of font sized up and down

Value

The following values are acceptable:

  • 1, 2, 3, 4, 5, 6, 7
  • +1, +2, +3, +4, +5, +6
  • -1, -2, -3, -4, -5, -6

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

It causes no compatibility issues, and has excellent support across all tested browsers.

User-contributed notes

There are no comments yet.

Related Products