W3docs

HTML <font> Tag

The <font> tag defines the size, typeface, and color of their text.characteristics. Not supported in HTML5. Learn how to use <font> tag. See examples.

The <font> tag defines font characteristics. Size, color, and typeface are controlled by the size, color, and face attributes.

Danger

The <font> tag is a deprecated HTML tag. Instead of it, use CSS styles (see an example below).

Syntax

The <font> tag comes in pairs. The content is written between the opening (<font>) and closing (</font>) tags.

Example of using HTML <font> tag:

Example of HTML <font> Tag

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <p>
      <font size="2" color="#1c87c9">Blue text</font>
    </p>
    <p>
      <font size="3" color="red">Red text, font size increased.</font>  
    </p>
    <p>
      <font face="arial" color="#8ebf42">Green text, typeface changed.</font>
    </p>
  </body>
</html>

Result

font tag example

CSS Styles

To change the text color, use the CSS color property instead of the color attribute. CSS font-family replaces the face attribute, and instead of the size attribute, the CSS font-size property is used.

Example of changing the style of the text with CSS:

An example where using CSS color, font-family, font-size properties instead of color, face and size attributes

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <p style="font-size:16px; color:#1c87c9;">Blue text.</p>
    <p style="font-size:18px; color:red;">Red text, font size increased.</p>
    <p style="font-size:18px; color:#8ebf42; font-family:arial;">Green text, typeface changed.</p>
  </body>
</html>

Attributes

AttributeValueDescription
colorrgb (x, x, x) #xxxxxx colornameSets the color of the text.
facefont_familySets the typeface.
sizenumberSets the size of the text.

Practice

Practice

What are the features of the HTML Font tag?