Live Preview
How <font> styled text historically (browsers still render it for compatibility):
Styled Text Here
This is a green word in a sentence.

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.
How <font> styled inline text with attributes.
Why HTML5 removed <font> from the specification.
Legacy attributes that controlled text appearance.
Replace the color attribute with stylesheets.
Modern replacements for face and size.
Recognize font in old tutorials and migrate to CSS.
<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.
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.
.highlight {
color: #2563eb;
font-family: Arial, sans-serif;
font-size: 1.125rem;
}Wrap styled text between opening and closing <font> tags. Set attributes on the opening tag:
<font size="4" color="blue" face="Arial">Styled Text Here</font><font> is an inline element—it wraps words or phrases inside block content.color and face are deprecated in HTML5.<font />) is not valid in HTML.<font> tags unless maintaining very old code.| Use Case | Code Snippet | Notes |
|---|---|---|
| Legacy styling | <font color="red">Text</font> | Obsolete — legacy render |
| Text color | color: #2563eb; | Preferred CSS replacement |
| Font family | font-family: Arial, sans-serif; | Replaces face attribute |
| Font size | font-size: 1.125rem; | Replaces size attribute |
| Modern markup | <span class="highlight"> | Generic inline + CSS class |
| HTML5 status | Obsolete | Removed from specification |
<font> vs CSS StylingChoose the right technique for text appearance:
| Method | Best for | HTML5 status |
|---|---|---|
<font> | Nothing — do not use | Obsolete |
color | Text and link colors | Modern CSS standard |
font-family | Typeface selection | Modern CSS standard |
font-size | Precise, accessible sizing with rem/em | Modern CSS standard |
<font> vs <span>Both wrap inline text, but only span fits modern HTML:
| Feature | <font> | <span> |
|---|---|---|
| Purpose | Presentational styling (obsolete) | Generic inline container |
| Styling attributes | size, color, face (deprecated) | None — use CSS classes |
| HTML5 status | Obsolete | Valid, widely used |
| Recommended today | No | Yes — pair with CSS |
The <font> tag had these deprecated presentational attributes. All are obsolete in HTML5—use CSS instead:
color DeprecatedSets text color by name or hex value.
color="blue"face DeprecatedDefines the font family (typeface name).
face="Arial"size DeprecatedLegacy size scale from 1 (smallest) to 7 (largest).
size="4"class / id GlobalCSS hooks—prefer a span with classes instead of font.
<span class="highlight"><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.
Historical <font> patterns plus modern CSS replacements. Legacy examples render for compatibility only—do not use in new code.
How <font> styled text historically (browsers still render it for compatibility):
Styled Text Here
This is a green word in a sentence.
Combine size, color, and face on a single <font> element.
<font size="4" color="blue" face="Arial">Styled Text Here</font>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.
Apply color to a single word inside a paragraph with the color attribute.
<p>This is a <font color="green">green</font> word in the middle of a sentence.</p>Color part of a heading inline—a pattern once common on early websites.
<h2>Welcome to our <font color="red">red-themed</font> website!</h2>This is what beginners should use today. A CSS class on <span> gives precise, maintainable control over text styling.
<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>Replace every font attribute with equivalent CSS properties:
color Replaces color attributefont-family Replaces face attributefont-size Replaces size attributeclass on span Reusable design tokens/* 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
Styled Text Here
This is a green word in a sentence.
Color alone does not convey meaning to all users:
strong, em, and headings convey meaning; font does not.Set size, color, and face on the opening tag.
Text rendered with the specified color, size, and typeface inline.
HTML5 moved font styling to stylesheets for separation of structure and presentation.
Learn font for history. Style text with CSS classes in all new projects.
Browsers still render <font> for backward compatibility, but the element is obsolete and not part of HTML5.
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.
HTML5 separated structure from presentation—text styling belongs in CSS.
color attribute on fontface and size attributesBottom line: Browsers still render <font> for old pages, but the tag is obsolete. Use CSS on <span> in every new project.
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.
color, font-family, and font-sizespan elementsstrong, em) for meaningfont only to read legacy HTML<font> in new projects<font>Bookmark these before you ship — they’ll keep your markup modern and accessible.
<font> is removed from HTML5.
Replaces the color attribute.
Replaces the face attribute.
Replaces the legacy size scale.
Modern inline styling pattern.
ModernBrowsers still show old font markup.
Compatibilitysize, color, and face attributes directly in HTML.font is obsolete and removed from the HTML5 specification. Browsers render it only for backward compatibility.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.font only to recognize it in old tutorials and legacy code.Replace font with span and CSS in the interactive HTML editor.
6 people found this page helpful