What Are <font> and <basefont> Tags?
<font> tag
Back in the early days of HTML, the <font>
tag was used to directly style text — you could set the font type, size, and color right in the HTML.
The downside? You had to add it every time you wanted styled text.
Example:
<font
face="Arial"
size="4"
color="blue">
This is blue Arial text, size 4.
</font>
This is blue Arial text, size 4.
</font>
<basefont> tag
This tag was like a “global font setting” for your page. Once you set it, all the text on the page would use that font, size, and color — unless a <font> tag overrode it.
<font
face="Arial"
size="4"
color="blue"
>
This is blue Arial text, size 4.
</font>
This is blue Arial text, size 4.
</font>
Why Are They Deprecated?
- Both
&l;font>
and&l;basefont>
are outdated because: - The
&l;basefont>
tag is deprecated in HTML 4 and completely removed from HTML 5. Instead of using this tag, we can use the CSS properties to style the document. - They’re hard to maintain (you’d need to edit multiple places to change a style).
- They mix design with content, making code messy.
- They aren’t responsive for mobile and modern devices.
- CSS came along, making them unnecessary.
<!DOCTYPE html>
<html>
<head>
<title>HTML basefont Example</title>
</head>
<body>
<basefont face="Arial, Helvetica" color="blue" size="5">
<p>This text is styled using the <code><basefont></code> tag.</p>
<p>It sets the default font face, size, and color for the entire page.</p>
<p><b>Note:</b> The <code><basefont></code> tag is deprecated and should be replaced with CSS.</p>
</body>
</html>