HTML <basefont> tag

The <basefont> tag is used to set the default font-color, font-family and font-size in a web-page or document. This tag is not supported in HTML5. The base URL is valid only when you have not assigned the specific href value for an HTML <a> element.

Type: Null or empty tag

Syntax of <basefont> tag

<basefont color="blue" size="6" face="Arial">

If you set as above within <head> element, all the texts will be red in color, font-size will be 6 (1-7 is defined) and font-family will be Arial for the whole document in the page.

Characteristics of <base> tag

  1. The <basefont> tag is considered as one of the empty tag because it has no end tag (</basefont>).
  2. It must be defined within the <head> element like
  3. It is an optional meta tag, meaning it may or may not be added, depending on the author.
  4. The maximum <basefont> element that be can defined within a document is only one.
  5. To define <basefont> tag, you must use either at least one of the color, face and size attributes or you may use all of them. The following exampple is wrong.
    <head>
      <basefont>
    </head>
    

Supported Browsers

Tag Chrome Internet Explorer Firefox Safari Opera Mini
<basefont> No No No No No

In HTML 4.01, <basefont> tag is supporetd. Inorder to illutrate the output section, we have to write the document in HTML 4.01.

Full code example

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<basefont
color="blue"
size="4"
face="Arial">
</head>
<body>
<p> The texts within this paragraph will be blue color having 4 size with Arial font. </p>
</body>
</html>
Run The code »

Output on the browser

The texts within this paragraph will be blue color having 4 size with Arial font.

Attributes of <basefont> tag

There are three attributes of <basefont> tag:- color and size and target. You can use all of the attributes or single. Note that if you use neither of its attribute to the <basefont> tag, you have no reason for assigning this tag.

Attribute Value
color It defines the default text-color in a document.
size It defines the default font-size in a document.
face It defines the default font-family in a document.

All the above three attributes are not supported in HTML5. Their uses can be replaced with the help of CSS.

  • color attribute can be replaced by CSS color property.
  • size attribute can be replaced by CSS font-size property.
  • face attribute can be replaced by CSS font-family property.