HTML Fonts: An Introduction to the Font Tag


The <font> tag in HTML is used to specify the font, color, and size of text. The <font> tag is now considered deprecated, which means it is no longer recommended for use and may not be supported in future versions of HTML. Instead, it's better to use CSS to style text.

The <font> tag takes several attributes, including:

  • face: This attribute specifies the font to be used.
  • size: This attribute specifies the size of the text. The size can be specified as a number (1-7) or as a relative value (e.g. +1, -2).
  • color: This attribute specifies the color of the text. The color can be specified as a named color (e.g. "red"), as a hexadecimal color code (e.g. "#FF0000"), or as an RGB value (e.g. "rgb(255,0,0)").

Here is the simple example program for printing the text within the font tag

Source Code

<html>
  <head>
    <title>Font Tag</title>
  </head>
  <body>
    <h1>Font Tag</h1>
	<font face="roboto" size='5' color="red">
	<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>
	</font>
  </body>
</html>
To download raw file Click Here

This code creates an HTML document with a title of "Font Tag" in the head. In the body of the document, there is a heading with the text "Font Tag" and a paragraph of text that is contained within a <font> tag.

The <font> tag has three attributes:

  • face: This attribute specifies the font family to be used for the text within the tag. In this case, the font family is "roboto".
  • size: This attribute specifies the size of the text within the tag. In this case, the size is '5'.
  • color: This attribute specifies the color of the text within the tag. In this case, the color is "red".

So, the paragraph text "Lorem ipsum dolor sit amet, consectetuer adipiscing elit." will be displayed in the Roboto font, with a size of 5 and in red color.