HTML - <font> Tag
The HTML <font> tag is used to specify the font of the text. Using this tag and its attributes, we can change the color, size, and font face of the text.
The <font> tag is deprecated in HTML5 and is no longer recommended. Instead, we should use CSS properties to change the font size, color, and other styles.
Syntax
Following is the syntax of <font> tag −
<font size=" " color=" " face=" "> ....</font>
Attributes
The HTML <font> tag supports both Global and Event attributes. It also accepts some specific attributes which are listed bellow.
| Attribute | Value | Description |
|---|---|---|
| color |
rgb(x,x,x) #hexcode colorname |
Deprecated − Specifies the color of the text. |
| face | List of font names | Deprecated − Specifies the font families. |
| size | number | Deprecated − Specifies the font size from 1 to 7. |
Example: Changing the Font Size
In this example, we will use the size attribute to change the font size, and also demonstrate an alternative method using CSS> This HTML code compress the <font> tag with CSS for setting text size.
<!DOCTYPE html>
<html>
<head>
<title>HTML font Tag</title>
</head>
<body>
<!-- Using attribute -- >
<font size = "5">
The HTML font tag is now deprecated.
You should start using CSS to set
font size and family.
</font>
<!-- Using CSS -- >
<p style="font-size:24px">
The HTML font tag is now deprecated.
You should start using CSS to set
font size and family.
</p>
</body>
Example: Changing the Font Color
In the following example, we will use the color attribute to change the font color, and also demonstrate an alternative method using CSS.
<!DOCTYPE html>
<html>
<head>
<title>HTML font Tag</title>
</head>
<body>
<!-- Using attribute -- >
<font color = "#ff9900">
The HTML font tag is now deprecated.
You should start using CSS to set
font size and family.
</font>
<!-- Using CSS -- >
<p style="color:#ff9900">
The HTML font tag is now deprecated.
You should start using CSS to set
font size and family.
</p>
</body>
</html>
Example: Changing the Font Style
Here, we will use the face attribute to change the font face, and also demonstrate an alternative method using CSS.
<!DOCTYPE html>
<html>
<head>
<title>HTML font Tag</title>
</head>
<body>
<!-- Using attribute -- >
<font face = "cursive,serif">
The HTML font tag is now deprecated.
You should start using CSS to set
font size and family.
</font>
<!-- Using CSS -- >
<p style="font-family: cursive,serif;">
The HTML font tag is now deprecated.
You should start using CSS to set
font size and family.
</p>
</body>
</html>
Supported Browsers
| Tag | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| font | Yes | Yes | Yes | Yes | Yes |




