Open In App

HTML font color Attribute

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

HTML font color attribute specifies the text color of content inside the <font> tag. The font color attribute accepts a color value that we want to apply to a text and it will be displayed on the screen having that mentioned color.

Syntax:

<font color="color_name|hex_number|rgb_number">

Attribute Values:

  • color_name: It sets the text color by using the color name. For example: “red”.
  • hex_number: It sets the text color by using color hex code. For example: “#0000ff”.
  • rgb_number: It sets the text color by using rgb code. For example: “rgb(0, 153, 0)”.

Note: The <font> color attribute is not supported by HTML5. 

Example to Set Font Color in HTML

We can use the color attribute of the font tag to set a font color in HTML. We can assign a color value using a color name, hex code, or RGB code.

Let’s understand it better with example:

Example: In this example, we are getting the colored text by using the color attribute having three different types of values. We have used color name value, hex code value, and RGB code value to set the font color of three different text elements.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>
        HTML | <font> color Attribute
    </title>
</head>

<body>
    <font size="6" face="verdana" color="green">
        GeeksforGeeks!
    </font>
    <br>

    <font size="6" face="arial" color="#008000">
        GeeksforGeeks!
    </font>
    <br>

    <font size="6" color="rgb(128, 128, 0)">
        GeeksforGeeks!
    </font>
</body>

</html>

Output:

font color html using color attribute

Supported Browsers

You can view the set font colors HTML using these browsers. The browsers support color attribute of font tag, and display the changes in text color.

HTML is the foundation of webpages, is used for webpage development by structuring websites and web apps.You can learn HTML from the ground up by following this HTML Tutorial and HTML Examples.


Last Updated : 15 Mar, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads