Description

The HTML element <font> is used to define a font style for its text, which can apply font face, font size, and font color.

This element is not supported in HTML5 and you should avoid using it in the markup. Instead, use CSS font properties.

The below table summarizes its usage.

Usage Details
Placement It is displayed as an Inline element.
Contents It can contain Inline elements and text.
Tags Both the opening and closing tags are required.
Versions HTML 3.2, 4, 4.01
This element is deprecated in HTML 4.01 and obsolete since HTML5, so avoid using this element in your markup.
Instead, use the CSS font properties.

Syntax

Here is the basic syntax of the <font> element.

<font face="font-family, ..." size="number" color="color">...</font>

Examples

Run this on IDE

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Example - HTML Element font</title>
</head>
<body>
    <!-- This element is obsolete and not valid in HTML5, so avoid using it in your markup -->
    <p>This paragraph contains a <font size="5" color="red">text</font> that is styled using font element.</p>
    <!-- Alternative and better way is to use CSS font properties as shown below. -->
    <p>This paragraph contains a <span style="font-size: 18px; color: green;">text</span> that is styled using CSS font properties.</p>
</body>
</html>

Attributes

The following table shows the list of supported and unsupported attributes for the <font> element.

Attribute Type Details
Element-Specific Attributes The tag <font> has some element-specific attributes listed in the below table.
Global Attributes Like all other HTML tags, the tag <font> supports the HTML Global Attributes.
Event Attributes The tag <font> also supports the HTML Event Attributes.

Here is a list of attributes that are specific to the <font> element.

Attribute Value Required Description
face font-family No Obsolete
Specifies the font family for the text.
size number No Obsolete
Specifies the font size for the text.
color color No Obsolete
Specifies the font color for the text.

Browser Compatibility

The tag <font> is supported in all modern browsers.

  • Google Chrome 1+
  • Internet Explorer or Edge 2+
  • Firefox 1+
  • Apple Safari 1+
  • Opera 4+

Related Links