HTML <basefont> Tag

Beginner
5 min read
Updated: Oct 2026
3 examples
Deprecated

Definition and Usage

The <basefont> element once set a document default font — size, color, and face (family) — usually near the start of <body>.

Learn it only to recognize legacy pages and migrate them. For every new project, style defaults with CSS on body (font-family, font-size, color).

Deprecated / Obsolete.

Do not use <basefont> in new HTML. It was removed from HTML5. Support was never consistent; modern browsers largely ignore it.

CSS replacement.

A single body { … } rule gives clearer, reliable document defaults than presentational tags ever did.

HTML Syntax

syntax.html
<basefont size=" n" color="…" face="…">

Historically a void element (no end tag). Modern equivalent: body { font-size: …; color: …; font-family: …; }

Attributes

Legacy presentational attributes (study only). Prefer the CSS column in new work:

AttributeDescriptionTry it
sizeLegacy scale 1–7 (default often 3) or relative +1 / -1 → use CSS font-sizeTry it
colorNamed or hex text color → use CSS colorTry it
faceComma-separated font names → use CSS font-familyTry it
(use CSS)Correct today — style body (or a shared stylesheet)Try it

Global Attributes

The <basefont> tag also supports the Global Attributes in HTML (legacy recognition only — do not ship new markup).

Live Preview

Preview the CSS replacement for document defaults. Modern browsers ignore <basefont>, so this demo styles a sample with CSS instead.

Equivalent to what authors once hoped <basefont> would do — done correctly with CSS.

Sample text

Default document text should be easy to read. Style it with CSS on body, not with obsolete tags.

Using browser default sample styles.

HTML Examples

Short snippets for study and migration. Use Try It Yourself for a live editor.

Example 1 — Legacy basefont (Study Only)

Recognize old markup. Do not copy this into new projects.

HTML
<!-- Deprecated — for study only -->
<body>
  <basefont color="#334155" face="Helvetica, Arial, sans-serif" size="4">
  <p>Page text would inherit these defaults in some old browsers.</p>
</body>
Try It Yourself

How It Works

  1. Spot the void tag early in <body>.
  2. Read size, color, and face as the intended defaults.
  3. Expect little or no effect in current browsers.
  4. Plan a CSS migrate instead of keeping the tag.

Example 2 — Modern CSS on body

Same intent as basefont defaults — reliable and supported.

HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>CSS instead of basefont</title>
  <style>
    body {
      font-family: Helvetica, Arial, sans-serif;
      font-size: large;
      color: #334155;
      margin: 1rem;
      line-height: 1.5;
    }
  </style>
</head>
<body>
  <p>Document defaults come from CSS, not basefont.</p>
</body>
</html>
Try It Yourself

How It Works

  1. Put defaults in a stylesheet (or a <style> in <head>).
  2. Target body so children inherit the look.
  3. Map face → font-family, size → font-size, color → color.
  4. Delete <basefont> from the HTML.

Example 3 — Map Legacy Attributes to CSS

Quick translation when cleaning old pages.

HTML
<!-- Was: <basefont size="4" color="#c00" face="Georgia, serif"> -->
<style>
  body {
    font-size: large;           /* ~ size="4" */
    color: #c00;                /* color */
    font-family: Georgia, serif; /* face */
  }
</style>
Try It Yourself

How It Works

  1. Find each presentational attribute on the old <basefont>.
  2. Write the matching CSS property on body.
  3. Prefer modern units (rem, em) over the old 1–7 scale when redesigning.
  4. Also migrate <font> spans the same way if they appear nearby.

Edge Cases & Pitfalls

The main risk is assuming ignored markup still sets typography.

obsolete

Never ship new <basefont>

HTML5 removed it. Validators will flag it; authors must use CSS.

support

Support was never consistent

Even historically, browsers disagreed. Relying on it always produced fragile layouts.

migrate

Ignoring the tag can change page look

If a legacy site “worked” only in an old UA, move the intended defaults into CSS explicitly.

related

Do not swap in <font>

<font> is also obsolete. Replace both with CSS properties.

size

The 1–7 scale is a rough map only

There is no exact CSS equivalent for every browser’s old size table. Redesign with modern units.

Browser Support

The <basefont> element is obsolete HTML. It is not part of modern authoring and is not a Node.js, Deno, or Bun API.

✓ Deprecated · Largely ignored

<basefont>

Removed from HTML5. Most modern browsers parse the tag but do not apply its presentational defaults. Use CSS for document fonts.

0% Authoring use (new pages)
Google Chrome Ignored (legacy)
Obsolete
Mozilla Firefox Ignored (legacy)
Obsolete
Apple Safari Ignored (legacy)
Obsolete
Microsoft Edge Ignored (legacy)
Obsolete
Opera Ignored (legacy)
Obsolete
Samsung Internet Ignored (legacy)
Obsolete
Internet Explorer Legacy effect
Obsolete
<basefont> Do not use

Bottom line: Recognize it in old documents; replace with body CSS. Never teach it as a current technique.

Key Takeaways

  • Status: <basefont> is obsolete — do not use it in new HTML.
  • Replace: font-family, font-size, and color on body.
  • Legacy attrs: size, color, and face were presentational only.
  • Also obsolete: migrate <font> the same way when you find it.

One line: treat <basefont> as history, and set document fonts with CSS.

Default CSS Settings

Modern user agents do not apply meaningful presentational defaults from <basefont>. There is nothing reliable to style on the element itself. Use CSS like this instead:

replacement.css
/* Replacement for obsolete <basefont> defaults */
body {
  font-family: system-ui, sans-serif;
  font-size: 1rem;
  color: #111;
}

Adjust family, size, and color to match the design — not the old 1–7 size table.

Frequently Asked Questions

No. basefont is obsolete in HTML. Do not use it in new pages. Set default typography with CSS on body (or a stylesheet) instead.
It once set a document-wide default font size, color, and face (font family). Text after it could inherit those presentational defaults in some legacy browsers.
Use CSS: font-family, font-size, and color on body (or a shared class). That is clearer, more controllable, and supported everywhere.
Usually they still display, but modern browsers largely ignore basefont, so the intended default font often never applies. Migrate those pages to CSS.
Legacy size used absolute values 1–7 (3 was the typical default) or relative values like +1 / -1. Map those ideas to CSS font-size with rem, em, %, or keywords such as large.
No. basefont tried to set a document default; font styled a span of text. Both are obsolete presentational elements — replace both with CSS.

Next: bdi

Isolate bidirectional text so mixed scripts and numbers stay readable.

bdi tutorial →

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.

8 people found this page helpful