Skip to content

<font> - Font Styling (Deprecated)

Deprecated HTML 3.2

The <font> element was used in early HTML to change the color, size, and typeface of text. It was one of the presentational elements that mixed content with styling, which modern web development separates using CSS.

<font color="red" size="5" face="Arial">Styled text</font>

The <font> element supported three main attributes for controlling text appearance:

AttributeDescriptionValues
colorText colorColor name (e.g., red, blue) or hex value (e.g., #FF0000)
sizeFont size on a scale1 to 7 (default: 3), or relative values (+1, -2)
faceFont typefaceComma-separated list of font names (e.g., Arial, Helvetica)

This example shows how the <font> element was used in older HTML documents:

Result

The <font> element was deprecated and removed for several important reasons:

1. Separation of Concerns

HTML should describe the structure and meaning of content, not its presentation. Mixing styling directly into HTML makes code harder to maintain and update.

2. Poor Maintainability

Changing the appearance of a site required editing every single <font> tag. With CSS, you can update styles site-wide by changing a single stylesheet.

3. Limited Flexibility

The <font> element offered only basic styling options. CSS provides hundreds of properties for precise control over typography, including line-height, letter-spacing, font-weight, text-shadow, and more.

4. Accessibility Issues

The arbitrary size scale (1-7) didn’t respect user preferences for text size. Modern CSS units like em and rem scale with user settings, improving accessibility.

5. Performance

Inline styles in HTML increase page size. External CSS files can be cached by browsers, improving load times.

Use CSS properties to achieve the same effects with better control and maintainability.

Replace color attribute with the CSS color property:

Result

Replace size attribute with the CSS font-size property:

Result

Replace face attribute with the CSS font-family property:

Result

Combine multiple font properties using the CSS font shorthand:

Result

Here’s how to convert common <font> patterns to modern CSS:

<!-- Color only -->
<font color="red">Red text</font>
<!-- Size only -->
<font size="5">Large text</font>
<!-- Font face only -->
<font face="Arial">Arial text</font>
<!-- All attributes -->
<font color="blue" size="4" face="Verdana">
Styled text
</font>
<!-- Nested fonts (common but messy) -->
<font size="6">
<font color="green">
<font face="Arial">
Multiple attributes
</font>
</font>
</font>
<!-- HTML file -->
<link rel="stylesheet" href="styles.css">
<p class="intro">This is introductory text</p>
<p class="highlight">This is highlighted text</p>
<p class="warning">This is warning text</p>
styles.css
.intro {
font-size: 18px;
font-family: Georgia, serif;
color: #333;
line-height: 1.6;
}
.highlight {
font-size: 20px;
font-family: Arial, sans-serif;
color: #0066cc;
font-weight: bold;
}
.warning {
font-size: 16px;
font-family: Arial, sans-serif;
color: #cc0000;
font-weight: bold;
}

The <font> element’s size attribute used values 1-7. Here’s an approximate conversion to modern CSS:

<font size>Approximate CSSRelative to Default
110px or 0.63emSmallest
213px or 0.82emSmall
316px or 1emDefault
418px or 1.13emMedium-large
524px or 1.5emLarge
632px or 2emLarger
748px or 3emLargest

The <font> element was supported by all major browsers during its lifetime:

BrowserSupportedRemoved
Chrome1-CurrentStill renders (legacy support)
Firefox1-CurrentStill renders (legacy support)
Safari1-CurrentStill renders (legacy support)
Edge12-CurrentStill renders (legacy support)
IE3-11Still rendered in IE11

Generic inline container for styling text with CSS. The modern replacement for <font>. Learn more →