HTML HTML Tutorial HTML Forms HTML Graphics HTML Media HTML APIs HTML Tags



HTML Tag: font

The <font> tag is an HTML element that is used to define the font size, color, and face of the text content within a web page. This tag was widely used in the early days of web development, but it has since been deprecated in favor of using Cascading Style Sheets (CSS) to style text.

Brief Explanation of HTML Tag: font

The <font> tag has three main attributes:

  • size: This attribute is used to specify the size of the font. It can be set to a value between 1 and 7, with 1 being the smallest and 7 being the largest.
  • color: This attribute is used to specify the color of the font. It can be set to a named color (e.g. red, blue, green) or a hexadecimal value (e.g. #FF0000 for red).
  • face: This attribute is used to specify the font face or typeface. It can be set to a specific font family (e.g. Arial, Times New Roman) or a generic font family (e.g. serif, sans-serif).

Here are some examples of how the <font> tag can be used:

Example 1: Setting the Font Size

To set the font size of a paragraph to 24 pixels, you can use the following code:

<p><font size="6">This text is 24 pixels in size</font></p>

This will result in the following output:

This text is 24 pixels in size

Example 2: Setting the Font Color

To set the font color of a paragraph to red, you can use the following code:

<p><font color="red">This text is red</font></p>

This will result in the following output:

This text is red

Example 3: Setting the Font Face

To set the font face of a paragraph to Arial, you can use the following code:

<p><font face="Arial">This text is in Arial</font></p>

This will result in the following output:

This text is in Arial

Conclusion

The <font> tag is a deprecated HTML element that was used to style text in the early days of web development. While it is still supported by most web browsers, it is recommended to use CSS to style text instead. This allows for more flexibility and control over the appearance of text on a web page.

References

Activity