HTML <font> tag is employed to specify the font style for the text enclosed within it. It sets the font size, color, and typeface of the text in an HTML document.
NOTE: Do not use HTML <font> tag as it is deprecated in HTML5, so you can use CSS properties to change the font size, face, color, etc.
Syntax
Example
<font size=" " color=" " face=" "> Content....</font>
Here are some details regarding the HTML <font> element:
| Display | Inline |
|---|---|
| Start tag/End tag | Both Start and End tag |
| Usage | Font Style |
Example 1
Example
<!DOCTYPE html>
<html>
<head>
<title>Font Tag</title>
</head>
<body>
<h2>Example of font tag</h2>
<p>This is normal text without any font styling</p>
<p>
<font color="blue">Text with normal size and default face</font>
</p>
<p>
<font size="5" color="green">Text with Increased size and default face</font>
</p>
<p>
<font color="red" face="cursive">Text with Changed face</font>
</p>
</body>
</html>
Output:
Using CSS
Equivalent results can be attained by utilizing CSS attributes, as demonstrated in the following instance:
Example
<!DOCTYPE html>
<html>
<head>
<title>Font Tag</title>
</head>
<body>
<h2>Change font using CSS</h2>
<p>This is normal text without any font styling</p>
<p style="color: blue;">Text with normal size and default face</p>
<p style="font-size: 25px; color: green;">Text with Increased size and default face </p>
<p style="font-family: cursive; color: red;">Text with Changed face</p>
</body>
</html>
Output:
Attribute
Tag-specific attribute
| Attribute | Value | Description |
|---|---|---|
| colod | rgb(X,X,X)#xxxxxcolor_name | It specifies the color of the content. (Not Supported in HTML5) |
face |
font_family | It specifies the typeface of the content. (Not Supported in HTML5) |
size |
number | It specifies the size of the content. (Not Supported in HTML5) |
Supporting Browsers
| Element | Chrome | IE | Firefox | Opera | Safari |
|---|---|---|---|---|---|
<font> |
Yes | Yes | Yes | Yes | Yes |