HTML <font> Tag

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Text & Styling

What You’ll Learn

By the end of this tutorial, you’ll understand legacy font markup and the modern CSS techniques that replaced it.

The HTML <font> tag was historically used for styling text on web pages. This guide covers its syntax, deprecated attributes, use cases, best practices, and browser support so beginners can recognize old code and write modern CSS instead.

01

Historical Syntax

How <font> styled inline text with attributes.

02

Obsolete Status

Why HTML5 removed <font> from the specification.

03

size, color, face

Legacy attributes that controlled text appearance.

04

CSS color

Replace the color attribute with stylesheets.

05

font-family & font-size

Modern replacements for face and size.

06

Legacy Maintenance

Recognize font in old tutorials and migrate to CSS.

What Was the <font> Tag?

The <font> element was an inline HTML tag used for presentational text formatting. It let developers control font size, color, and font family directly in HTML using the size, color, and face attributes.

⚠️
Obsolete in HTML5 — Use CSS

Do not use <font> in new projects. Use CSS color, font-family, and font-size on a <span> with a class instead. Browsers still render the tag for backward compatibility only.

HTML5 moved presentational styling to stylesheets. Learn <font> to read legacy HTML, but style text with CSS in all new work.

use-css-instead.css
.highlight {
  color: #2563eb;
  font-family: Arial, sans-serif;
  font-size: 1.125rem;
}

📝 Syntax (Historical)

Wrap styled text between opening and closing <font> tags. Set attributes on the opening tag:

syntax.html
<font size="4" color="blue" face="Arial">Styled Text Here</font>

Syntax Rules

  • <font> is an inline element—it wraps words or phrases inside block content.
  • Attributes like color and face are deprecated in HTML5.
  • Self-closing syntax (<font />) is not valid in HTML.
  • Do not nest multiple <font> tags unless maintaining very old code.

⚡ Quick Reference

Use CaseCode SnippetNotes
Legacy styling<font color="red">Text</font>Obsolete — legacy render
Text colorcolor: #2563eb;Preferred CSS replacement
Font familyfont-family: Arial, sans-serif;Replaces face attribute
Font sizefont-size: 1.125rem;Replaces size attribute
Modern markup<span class="highlight">Generic inline + CSS class
HTML5 statusObsoleteRemoved from specification

⚖️ <font> vs CSS Styling

Choose the right technique for text appearance:

MethodBest forHTML5 status
<font>Nothing — do not useObsolete
colorText and link colorsModern CSS standard
font-familyTypeface selectionModern CSS standard
font-sizePrecise, accessible sizing with rem/emModern CSS standard

⚖️ <font> vs <span>

Both wrap inline text, but only span fits modern HTML:

Feature<font><span>
PurposePresentational styling (obsolete)Generic inline container
Styling attributessize, color, face (deprecated)None — use CSS classes
HTML5 statusObsoleteValid, widely used
Recommended todayNoYes — pair with CSS

🧰 Attributes

The <font> tag had these deprecated presentational attributes. All are obsolete in HTML5—use CSS instead:

color Deprecated

Sets text color by name or hex value.

color="blue"
face Deprecated

Defines the font family (typeface name).

face="Arial"
size Deprecated

Legacy size scale from 1 (smallest) to 7 (largest).

size="4"
class / id Global

CSS hooks—prefer a span with classes instead of font.

<span class="highlight">
attributes.html
<font size="4" color="blue" face="Arial">Styled Text Here</font>

The entire <font> element and its attributes are obsolete. Use CSS on span or semantic elements in new projects.

Examples Gallery

Historical <font> patterns plus modern CSS replacements. Legacy examples render for compatibility only—do not use in new code.

Live Preview

How <font> styled text historically (browsers still render it for compatibility):

Styled Text Here

This is a green word in a sentence.

Attributes Example

Combine size, color, and face on a single <font> element.

⚠️ Obsolete tag — for learning only.
attributes.html
<font size="4" color="blue" face="Arial">Styled Text Here</font>
Try It Yourself

📚 Common Use Cases (Historical)

Developers once used <font> for colored words in paragraphs and headings. Today use <span> with CSS classes or semantic elements like <em> and <strong> for meaning, not just color.

Basic Text Styling

Apply color to a single word inside a paragraph with the color attribute.

basic-text-styling.html
<p>This is a <font color="green">green</font> word in the middle of a sentence.</p>
Try It Yourself

Inline Styling in a Heading

Color part of a heading inline—a pattern once common on early websites.

inline-styling.html
<h2>Welcome to our <font color="red">red-themed</font> website!</h2>
Try It Yourself

Modern CSS Replacement

This is what beginners should use today. A CSS class on <span> gives precise, maintainable control over text styling.

css-replacement.html
<style>
  .styled-text {
    color: #2563eb;
    font-family: Arial, sans-serif;
    font-size: 1.125rem;
  }
  .green-text { color: #16a34a; }
  .red-text   { color: #dc2626; }
</style>

<p><span class="styled-text">Styled Text Here</span></p>
<p>This is a <span class="green-text">green</span> word.</p>
<h2>Welcome to our <span class="red-text">red-themed</span> website!</h2>
Try It Yourself

Styling Text with CSS (Instead of <font>)

Replace every font attribute with equivalent CSS properties:

color Replaces color attribute
font-family Replaces face attribute
font-size Replaces size attribute
class on span Reusable design tokens
font-replacement.css
/* Replace font attributes with CSS */
.highlight {
  color: #2563eb;           /* was color="blue" */
  font-family: Arial, sans-serif; /* was face="Arial" */
  font-size: 1.125rem;       /* was size="4" */
}

.accent-green { color: #16a34a; }
.accent-red   { color: #dc2626; }

Live CSS-styled text

♿ Accessibility

Color alone does not convey meaning to all users:

  • Do not rely on color only — pair color with text, icons, or semantic elements for important information.
  • Use semantic tagsstrong, em, and headings convey meaning; font does not.
  • Check contrast — ensure text color meets WCAG contrast ratios against the background.
  • Avoid font in new work — it mixes presentation into HTML and hurts maintainability.

🧠 How <font> Worked

1

Author wrapped text in font

Set size, color, and face on the opening tag.

Markup
2

Browser applied presentational styles

Text rendered with the specified color, size, and typeface inline.

Rendering
3

CSS replaced presentational tags

HTML5 moved font styling to stylesheets for separation of structure and presentation.

Evolution
=

Today: use CSS on span

Learn font for history. Style text with CSS classes in all new projects.

Browser Support

Browsers still render <font> for backward compatibility, but the element is obsolete and not part of HTML5.

Obsolete · Use CSS styling

Legacy rendering only

All major browsers still apply font attributes for old pages, but the tag is removed from the HTML5 specification. Never use it in new projects.

95% Legacy rendering
Google Chrome Legacy render · Obsolete
Legacy render
Mozilla Firefox Legacy render · Obsolete
Legacy render
Apple Safari Legacy render · Obsolete
Legacy render
Microsoft Edge Legacy render · Obsolete
Legacy render
Internet Explorer Supported · EOL
Legacy render
Opera Legacy render · Obsolete
Legacy render

Why font was removed

HTML5 separated structure from presentation—text styling belongs in CSS.

🎨
CSS color Replace the color attribute on font
Replacement
📝
font-family & font-size Replace face and size attributes
Modern
<font> tag 95% legacy rendering

Bottom line: Browsers still render <font> for old pages, but the tag is obsolete. Use CSS on <span> in every new project.

Conclusion

While the <font> tag was once a go-to for text styling, it is now considered outdated. CSS provides a more flexible and maintainable approach that separates content from presentation.

Embrace modern web development practices: use span with CSS classes for colored or styled text, and semantic elements when meaning matters.

💡 Best Practices

✅ Do

  • Use CSS color, font-family, and font-size
  • Style text with classes on span elements
  • Use semantic tags (strong, em) for meaning
  • Learn font only to read legacy HTML

❌ Don’t

  • Use <font> in new projects
  • Rely on color alone to convey important information
  • Mix many inline font colors without a design system
  • Confuse presentational styling with semantic emphasis

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <font>

Bookmark these before you ship — they’ll keep your markup modern and accessible.

6
Core concepts
🎨 02

CSS color

Replaces the color attribute.

Replacement
📝 03

font-family

Replaces the face attribute.

Replacement
🔢 04

font-size

Replaces the legacy size scale.

Replacement
⚖️ 05

Use span + CSS

Modern inline styling pattern.

Modern
🌐 06

Legacy Render

Browsers still show old font markup.

Compatibility

❓ Frequently Asked Questions

It applied presentational text styling with size, color, and face attributes directly in HTML.
No. font is obsolete and removed from the HTML5 specification. Browsers render it only for backward compatibility.
CSS properties color, font-family, and font-size on a span with a class.
font was presentational and obsolete. span is a neutral inline container meant to be styled with CSS.
No. Beginners should use CSS for text styling. Learn font only to recognize it in old tutorials and legacy code.

Style Text the Modern Way

Replace font with span and CSS in the interactive HTML editor.

Try CSS replacement →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful