CLASS X: HTML FONT TAG IN HTML

The <font> tag in HTML was used in older versions of HTML to define the font face, size, and color of text. However, it is now considered obsolete in HTML5, and CSS is recommended for styling text instead. But for historical understanding, here’s how the <font> tag worked with its attributes:



<font> Tag Attributes

  1. face: Specifies the font family or typeface for the text. You can specify multiple font names as a fallback list.

    • Example:

      <font face="Arial, Helvetica, sans-serif">This is Arial font.</font>
    • Output: The text would be displayed in Arial (or Helvetica, if Arial is unavailable, or a generic sans-serif font).
  2. size: Specifies the size of the font. It can be set using either relative sizes (from 1 to 7, where 3 is the default) or absolute sizes (using a number or a + or - relative to the default size).

    • Example:

      <font size="4">This is size 4 font.</font>
      <font size="+2">This is size larger by 2.</font>
    • Output: The text would be larger or smaller depending on the size value.
  3. color: Specifies the color of the text. You can use color names or hexadecimal color codes.

    • Example:

      <font color="red">This text is red.</font>
      <font color="#00FF00">This text is green.</font>
    • Output: The text would appear in the specified color (red or green in these examples).

Example Using All Attributes


<font face="Verdana" size="5" color="blue">This is a blue, size 5 Verdana text.</font>
  • Output: The text would be displayed in blue, using the Verdana font at size 5.

Important Note:

The <font> tag is no longer recommended for use in modern web development. Instead, CSS is used to style text more effectively and consistently across different browsers. Here’s an equivalent example using CSS:


<p style="font-family: Verdana; font-size: 20px; color: blue;">This is a blue, size 5 Verdana text.</

Post a Comment

0 Comments