The <font> tag defines the font characteristics. Size, color и and typeface are defined by the size, color and face attributes.
The <font> tag is obsolete, use CSS styles instead (see an example below).
Syntax
The <font> tag comes in pairs; the content is written between the opening (<font>) and the closing (</font>) tags.
Example
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p>
<font size="2" color="#1c87c9">Blue text</font>
</p>
<p>
<font size="3" color="red">Red text, font size increased.</font>
</p>
<p>
<font face="arial" color="#8ebf42">Green text, typeface changed.</font>
</p>
</body>
</html>
Result
CSS Styles
To change the color of the text, CSS color property is used instead of the color attribute. CSS font-family or font-face properties come to replace the face attribute, and instead of the size attribute, the CSS font-size property is used.
Example
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p style="font-size:16px; color:#1c87c9;">Blue text.</p>
<p style="font-size:18px; color:red;">Red text, font size increased.</p>
<p style="font-size:18px; color:#8ebf42; font-family:arial;">Green text, typeface changed.</p>
</body>
</html>
Result
Attributes
Attribute | Value | Description |
---|---|---|
color | rgb (x, x, x) #xxxxxx colorname |
Sets the color of the text. |
face | font_family | Sets the typeface. |
size | number | Sets the size of the text. |
Browser support
|
|
|
|
|
---|---|---|---|---|