HTML <basefont> Element
The <basefont> element was historically used to establish a default font face, size, and color for text in an HTML document. It was a presentational element from an era when much of a webpage's visual appearance was controlled directly through HTML rather than CSS.
<basefont> element must not be used in new HTML. Use CSS properties such as font-family, font-size, and color to control the appearance of text.
Historical Syntax
Older HTML documents may contain markup similar to the following:
<basefont face="Arial" size="4" color="blue">
<p>This text uses the base font settings.</p>
This code is shown for historical reference only. The <basefont> element and its presentational attributes should not be used when creating or updating modern HTML.
Attributes
The <basefont> element historically used the following element-specific attributes to control the default appearance of text. These attributes are obsolete and are included only to help identify and understand older HTML source code.
| Attribute | Description |
|---|---|
color |
Specified the default text color for subsequent text in the document. |
face |
Specified the default font face or a list of preferred font faces. |
size |
Specified the default font size using the historical HTML font-size scale. |
Historical Use
The <basefont> element provided a way to establish general font settings for text that followed it in a document. Instead of repeatedly adding font information to individual pieces of text, an author could specify a base font face, size, or color that affected subsequent content.
Unlike a container element, <basefont> did not wrap the text it affected. It appeared in the document as an empty element and changed the presentation of text that followed according to the behavior supported by the browser.
Why It Became Obsolete
The <basefont> element mixed visual presentation with the structure of an HTML document. As CSS became the standard way to control webpage presentation, font faces, sizes, colors, spacing, and other visual properties no longer needed to be embedded directly in HTML markup.
Separating presentation from HTML makes styles easier to maintain, allows the same rules to be reused throughout a website, and provides much greater control over typography and responsive design. The <basefont> element was deprecated in HTML 4 and is obsolete in modern HTML.
Modern Alternative
Use CSS to establish default typography for a document. Applying font properties to the <body> element allows those values to be inherited by much of the text within the page.
body {
font-family: Arial, sans-serif;
font-size: 18px;
color: #333;
}
Legacy Browser Support
Support for the <basefont> element varied between browsers, and modern browsers should not be expected to reproduce its historical presentation consistently. A browser may still recognize the element while ignoring some or all of its obsolete font attributes.
Any remaining <basefont> markup should be replaced with CSS when an older website is updated. Browser recognition of obsolete markup is provided for compatibility with historical webpages and does not make the element valid for modern HTML.
For detailed legacy browser compatibility information, see Can I Use: HTML <basefont> Element .
Related Elements
The obsolete <basefont> element is closely related to the obsolete <font> element, which was used to control the appearance of individual portions of text. Modern HTML uses CSS for both document-wide and individual text styling.
Specifications
The <basefont> element is listed as an entirely obsolete, non-conforming feature in the WHATWG HTML Living Standard . Authors should use CSS to control font presentation instead.
