The Color is an attribute of <font> tag, which specifies the text color.
Syntax
<font color="Color_name|rgb_number|hex_number">
We can specify the text color with the following different attribute values:
- Color_name: This value sets the color of a text by the name of a color.
<font Color="Blue">
- Rgb_number: This value sets the color of a text by the RGB code.
<font color="rgb(128,128,0)"
<font color="#00FF00">
Examples: The following examples use the different value of color attribute:
Example 1: The following example uses the name of a color
<!DOCTYPE html>
<html>
<head>
<title>
Example of color attribute
</title>
</head>
<body>
<font color="orange">
<!-- The color attribute of font tag sets the color name 'orange' for the word javaTpoint-->
<center>
<h1>
javaTpoint
</h1>
</center>
</font>
</body>
</html>
Output:
Example 2: The following example uses the hex code for defining the text color:
<!DOCTYPE html>
<html>
<head>
<title>
Example of color attribute
</title>
</head>
<body>
<font color="#ff00ff">
<!-- The color attribute of font tag sets the color 'magenta' for the word javaTpoint by busing the Hex code "#ff00ff" -->
<center>
<h1>
javaTpoint
</h1>
</center>
</font>
</body>
</html>
Output:
Example 3: The following example uses the rgb number for defining the text color:
<!DOCTYPE html>
<html>
<head>
<title>
Example of color attribute
</title>
</head>
<body>
<font color="rgb(0,1,0)">
<!-- The color attribute of font tag sets the color 'maroon' for the word javaTpoint by using the RGB Number "rgb(0,1,0)" -->
<center>
<h1>
javaTpoint
</h1>
</center>
</font>
</body>
</html>
Output:
Example 4: The following example uses all the attribute values for the font color.
<!DOCTYPE html>
<html>
<head>
<title>
Example of color attribute
</title>
</head>
<body>
<center>
<h2> The color attribute of font tag sets the color 'maroon' for the following paragraph by using the RGB Number "rgb(0,1,0)" </h2>
</center>
<font color="rgb(0,1,0)">
<p>
HTML is an acronym which stands for Hyper Text Markup Language which is used for creating web pages and web applications. Let's see what is meant by Hypertext Markup Language, and Web page.
</p>
</font>
<center>
<h2> The color attribute of font tag sets the color 'orange' for the following paragraph by using the name of colour </h2>
</center>
<font color="orange">
<p>
HTML is an acronym which stands for Hyper Text Markup Language which is used for creating web pages and web applications. Let's see what is meant by Hypertext Markup Language, and Web page.
</p>
</font>
<center>
<h2> The color attribute of font tag sets the color 'magenta' for the following paragraph by busing the Hex code "#ff00ff" </h2>
</center>
<font color="#ff00ff">
<p>
HTML is an acronym which stands for Hyper Text Markup Language which is used for creating web pages and web applications. Let's see what is meant by Hypertext Markup Language, and Web page.
</p>
</font>
</body>
</html>
Output:
Browser Support
Element | Chrome | IE | Firefox | Opera | Safari |
<font color=””> | Yes | Yes | Yes | Yes | Yes |
Leave a Reply