W3docs

HTML <basefont> Tag

The <basefont> tag specifies the default font size and color of the text. It can be used several times inside the <head> or <body> tags. See examples.

The <basefont> tag set the default font size, color, and typeface for all text on a page. It could be placed inside the <head> or <body> tags, and every piece of text that didn't override the font would inherit those values.

This page explains what <basefont> did, why it was removed from HTML, and the exact CSS you should write today to get the same result.

Danger

The <basefont> is a deprecated HTML tag. It was removed in HTML5 and must not be used in new pages. The sections below show the modern CSS replacement.

Why <basefont> is deprecated

<basefont> is a presentational tag: it mixes styling information directly into the HTML markup. Modern HTML follows the principle of separation of concerns — HTML describes the structure and meaning of content, while CSS handles all presentation (fonts, colors, sizes, spacing). Because <basefont> only ever existed to set presentation, HTML5 dropped it entirely in favor of CSS.

Two practical consequences:

  • Browser support is unreliable. Even before HTML5, behavior varied between browsers, and modern browsers may ignore <basefont> completely. You cannot count on it rendering anything.
  • It is not valid HTML5. A document using <basefont> will fail validation, and tooling (linters, editors, frameworks) will flag it.

You may still run into <basefont> when maintaining older websites, email templates, or content management systems written before HTML5. When you do, the safe move is to delete the tag and replace it with the equivalent CSS shown below.

Syntax

The <basefont> tag is empty, which means that the closing tag isn’t required. But in XHTML, the (<basefont>) tag must be closed (<basefont/>).

Example of the HTML <basefont> tag:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <basefont color="green" face="Helvetica" size="14">
  </head>
  <body>
    <h3>Title of the text.</h3>
    <p>Paragraph of the text.</p>
  </body>
</html>

The modern CSS replacement

To reproduce exactly what <basefont> did, set the matching CSS properties on the body selector. Each old attribute maps one-to-one to a CSS property:

<basefont> attributeCSS propertyExample value
colorcolorgreen
facefont-familyHelvetica
sizefont-size14px

You can also write all three at once with the font shorthand.

Why target body? <basefont> worked by setting page-wide defaults that every element inherited unless it specified its own font. CSS reproduces this through the cascade: color, font-family, and font-size are inherited properties, so when you set them on body, every descendant element (headings, paragraphs, lists, and so on) inherits the same values automatically — unless a more specific rule overrides them. Styling body therefore gives you the same single source of truth that <basefont> once provided, but with valid HTML5 and reliable cross-browser behavior.

Example of the CSS replacement for <basefont>:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      body {
        color: green;
        font-family: Helvetica;
        font-size: 14px;
      }
    </style>
  </head>
  <body>
    <h3>Title of the text.</h3>
    <p>Paragraph of the text.</p>
  </body>
</html>

This produces the same green, 14px Helvetica text as the deprecated <basefont color="green" face="Helvetica" size="14"> example above — but it validates as HTML5 and renders consistently across browsers.

Attributes

AttributeValueDescription
colorcolorSets the default text color. Not supported in HTML5.
facefont_familyDefines the font of the text. Not supported in HTML5.
sizenumberSpecifies the font size. Not supported in HTML5.

Practice

Practice
What is true about the HTML <basefont> tag?
What is true about the HTML <basefont> tag?
Was this page helpful?