Font Tag in HTML

1
151

The <font> tag in HTML is used to define the font size, color, and face of text in a web page. Although it was widely used in the past, it is now considered deprecated and should be avoided in favor of CSS styles. However, it is still important to understand its syntax and functionality.

Syntax: The <font> tag has the following syntax:

<font size=”number” color=”color” face=”font_family”>text</font>

Attributes:

  • size: Specifies the size of the font. It can be a number from 1 to 7, where 1 is the smallest size and 7 is the largest.
  • color: Specifies the color of the font. It can be a color name, a hexadecimal value, or an RGB value.
  • face: Specifies the font family to be used. It can be a font family name, such as Arial or Times New Roman, or a generic font family, such as serif or sans-serif.

Example: Here is an example of how to use the <font> tag:

Also Read:  tr Tag in HTML

<p>This is <font size=”4″ color=”red” face=”Arial”>some text</font> in a web page.</p>

This will display the text “some text” in red color, Arial font, and with a font size of 4.

Alternatives: As mentioned earlier, the <font> tag is deprecated and should be avoided in favor of CSS styles. Here is an example of how the above code can be written using CSS:

<style>
p {
font-size: 16px;
font-family: Arial, sans-serif;
color: red;
}
</style>

<p>This is some text in a web page.</p>

This achieves the same result as the previous example, but with more modern and efficient code.

Conclusion: The <font> tag is a legacy HTML tag that is no longer recommended for use. Instead, it is recommended to use CSS to style text in a web page. However, it is still important to understand the syntax and functionality of the <font> tag, as it may be encountered in legacy code or when maintaining older websites.

1 COMMENT

Leave a Reply