Font Style Tags in HTML
- Font style refers to the size, color and style of characters typed in a document, email or web page.
- In other words, font styling lets you beautify the font as you wish.
<font> tag and its attributes.
The <font> tag allows us to set the font family, size and color of a small segment of text.
This small segment of text is typed between the opening and closing font tags.
<font> The text you want to beautify... </font>
Font Face
The Font Face element is used to change the typeface or name of the font
For Example: <font face ="Copperplate Gothic" >
Font Size
It is used to change the size of the font to be displayed.
Font sizes can be specified by using the numbers 1 to 7. The smallest font size is 1 and the largest is 7.
For Example: <font size ="4" >
Font Color
The color attribute changes the color of the text.
The color can be set by specifying the name of the color or by giving the hexadecimal code of the respective color
For Example: <font color ="#ff0000" >
Color Name | Hexadecimal Code |
---|---|
Cyan | #00ffff |
Teal | #008080 |
Blue | #0000ff |
Navy | #000080 |
Dark Blue | #0000a0 |
Light Blue | #add8e6 |
Purple | #800080 |
Magenta | #ff00ff |
Red | #ff0000 |
Maroon | #800000 |
Color Name | Hexadecimal Code |
---|---|
White | #ffffff |
Silver | #c0c0c0 |
Gray | #808080 |
Black | #000000 |
Olive | #808000 |
Green | #008000 |
Lime | #00ff00 |
Yellow | #ffff00 |
Orange | #ffa500 |
Brown | #a52a2a |
For Example:

Font Style Tags
Font Style tags let you display underlined, bold, italicized and many other styles.
Bold
The bold tag (<b>) is used when you want to display some Bold text.
Example : <b>Bold Text </b>
Italic
The italic tag (<i>) is used when you want to display text in Italic Style.
Example : <i>Italicized Text </i>
Underline
The Underline tag (<u>) is used when you want to underline text in your document.
Example : <u>Underlined Text </u>
Typewriter
The typewriter tag (<tt>) is used when you want to display the text in Typewriter Font.
Example : <tt>Typewiter Text </tt>
Strike
The Strike Tag (<strike> or <s>) draws a line through the middle of the text.
Example : <strike>Strike Tag </strike>
The Strike tag is not supported in HTML5.
Subscript
The Subscript tag (<sub>) is used when you want the text to be displayed at the base line. It is usually used to write Chemical Formulas like CH3CH2OH.
Example : CO <sub>2 </sub>
Superscript
The Superscript tag (<sup>) is used when you want the text to be displayed at the top line. It is usually used to write Mathematical Equations like a2 + b2 = c2
Example : (A + B) <sup>2 </sup> = A<sup>2 </sup> + B<sup>2 </sup> + 2AB
Preformatted
Web browsers consider only a single space between words, even if you give more than one space in the HTML document.
The Preformatted tag (<pre>) is used when you want to retain the spacing between the texts as you had given in your HTML document. It is usually used to type poems.
Example :
BaseFont
The <basefont> tag has attributes similar to the <font> tag, that is Font Face, Font Size and Color.
The <basefont>
tag is used to set font attributes for the entire HTML document.
For Example:
<basefont
face ="Forte"
size ="4"
>
If you want to change the font size of a particular element,
you can do so by adding or subtracting a value from the base font size initially set.
<font size= +2>
<font size= -1>
For Example:
<basefont
size ="4"
>
<p>The font size will be set to 4(i.e the BaseFont Size).
</p>
<font size= +2>
<p>The font size for this paragraph will be set to 6(i.e the BaseFont +2).
</p>
<font size= -1>
<p>The font size for this paragraph will be set to 3(i.e the BaseFont -1).
</p>
The <basefont> tag does not affect the heading tags in an HTML document.
The BaseFont tag is not supported in HTML5
For Example:
<html>
<head>
<title>Example | Kode.Blox
</title>
</head>
<body>
<basefont
size ="3">
<center>
<h1>
<i>Welcome to Kode.Blox!
</i>
</h1>
</center>
<hr
size ="3"
width ="94%"
color ="red"
>
<p>
<font
size = +3
color ="#0000ff"
>
<u>Question:
</u>
</font>
<font
size = +2
>
Speed of light in air is 3 x 10<sup>8
</sup> m/s
and Speed of light in glass is 2 x 10<sup>8
</sup> m/s.
Calculate the refractive index of glass.
</font>
</p>
<hr>
<p>
<font
size = +3
color ="#0000ff"
>
<u>Answer:
</u>
</font>
<font
size = "5"
>
Glass refractive index is defined as the ratio between the speed of light in the vacuum and the speed of light in the glass.
<br>
Refractive index of glass (
n<sub>g
</sub>)
= Speed of light in vacuum / speed of light in the glass.
<br>
n<sub>g
</sub> =
3 x 10<sup>8
</sup> /
2 x 10<sup>8
</sup>
<br>
n<sub>g
</sub> = 1.5
</font>
</p>
</body>
</html>