HTMLs Tutorial

HTML Tutorial HTML Tags HTML Basic Tags HTML Attributes HTML Elements HTML Formatting HTML Text Format HTML body tag HTML samp tag HTML script Tag HTML section tag HTML select tag HTML source tag HTML span tag HTML strike tag HTML strong tag HTML style tag HTML sub tag HTML summary tag HTML sup Tag HTML svg tag HTML table tag HTML u tag HTML Headings HTML Paragraphs HTML wbr tag HTML Anchor HTML Image HTML Lists HTML Ordered List HTML Unordered List HTML Form HTML Form input HTML with CSS HTML Layouts HTML References HTML Frames HTML Links Fieldset Tag in HTML Basic HTML Tags Br Tag in HTML Free HTML Templates How to Create a Table in HTML HTML Calendar HTML Card HTML Cellspacing HTML Center Image HTML Checkbox Read-only HTML Cleaner HTML Code for a Tab HTML Comment HTML Compiler HTML Nested Forms HTML Overlay Text on the Image HTML Select Option Default HTML Snake Game HTML Subheader HTML Tab Character dd Tag in HTML How Many HTML Tags are There HTML Align Tag HTML Responsive HTML Tab Code HTML Table Alternate Row Color HTML Table Fix Column Width Contact HTML DL Tag in HTML How to Insert Image in HTML HTML Background Color HTML Dark Mode How to Convert HTML to PNG HTML Data Toggle HTML Email Template HTML Font Color HTML Font Family ID and Class in HTML HTML Tab Space HTML Tab Tag HTML Itemprop HTML Itemscope HTML Form Design HTML Input Only Numbers HTML Textarea HTML to JPG HTML to Markdown Python li Tag in HTML MDN HTML What is the Correct HTML for Making a Hyperlink? What is the Root Element of an HTML Document How to Make a Box in HTML How to Save HTML Files in Notepad How to Align Text in HTML How to Change Font Color in HTML? How to Change Font Size in HTML How to Change Image Size in HTML How to Create a HTML Page How to Create a Link in HTML File? How to Create an HTML File? HR Tag in HTML HTML Base Tag HTML Default Attribute HTML Hyperlink HTML Indent HTML Injection Payloads HTML Input Numbers Only HTML Roadmap HTML Row Height HTML Schedule HTML Space HTML Tab HTML vs HTTP HTML5 API HTML5 Video HTML Collection to Array Text Area in HTML

HTML5 Advance

HTML5 Tutorial HTML5 Tags HTML Button Tag HTML canvas Tag HTML caption Tag HTML City tag HTML Tag HTML5 SVG HTML Event Attribute HTML5 Audio HTML5 Youtube HTML5 Button Tag HTML5 Tags

Misc

How to add JavaScript to HTML How to change font in HTML How to change text color in HTML HTML Date HTML Hide Element HTML Nested Table HTML Reset Button What does HTML stand for? HTML Background Image HTML Tag Div Tag in HTML How to insert Image in HTML How to create a link with no underline in HTML How to insert spacestabs in text using HTMLCSS HTML tag HTML Code HTML Tag HTML Canvas Design a tribute page using HTML and CSS What is a Container tag Font tag in HTML Difference between HTML and DHTML Empty Tag in HTML HTML Button Link Html Line Break Img src HTML Nested List in HTML Placeholder in HTML TD in HTML HTML Space Code HTML Target Attribute HTML Tag Markup Meaning in HTML Border-Collapse in HTML HTML Onclick Online HTML Compiler Convert HTML to PDF HTML Formatter HTML5 - Web Storage HTTP – Responses Container Tag in HTML DL Tag in HTML Horizontal Rule HTML HTML Tab Text Html Table Cell Background Color HTML Table Cell Color HTML Col Width How Many HTML Tags are There Convert String to Unicode Characters in Python HTML Runner HTML Style Attribute HTML Superscript Attribute HTML tabindex Marquee Tag in HTML HTML Dynamic Form HTML side Tag HTML Pattern Attribute HTML q Tag HTML Readonly Base 64 Encoding in HTML Documents Enhancing Data Portability and Security Evo Cam Web Cam HTML Free code camp HTML CSS How to Add a JS File in HTML? How to Add Picture in HTML How to Add the Logo in HTML? How to Add Video in HTML HTML Class Attribute HTML Entities HTML Form Elements HTML Form Templates HTML Marquee Tag HTML Radio Buttons HTML Text box HTML to JSX HTML Tooltip Basic HTML Codes How to Align Image Center in HTML HTML Header Tag HTML Image Tag HTML Next Line

HTML Font Color

The HTML <font> tag has an attribute called color, which defines the color of the text. We use the color attribute inside the <font> tag to specify the color of the text.

Syntax:

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

Following are the ways to define the font color:

Color name:

We use the color name to define the color of the text in an HTML document. The color name represents the specific name of the HTML color. There are 140 standard color names that HTML supports. You can use any color which you want to show in your HTML document. For example, if you want to change the text's color to purple, then you have to set the color of the text to purple.

Syntax:

<font color="Color_name ">  

RGB and RGBA number:

We use RGB and RGBA numbers to define the color of the text in an HTML document. The complete form of RGB is Red, Green, and Blue, and the full form of RGBA is Red, Green, and Blue with an Alpha, which defines opacity. We can create about 16 million different colors by combining red, green, and blue to form a color.

We can provide a color input value between 0 and 255, where 0 represents a color with minimum intensity and 255 represents a color with maximum intensity.

Syntax:

<font color="rgb(128,128,0)" 

Hex number:

We use hex numbers to define the color of the text in an HTML document. The Hex color code is the same as the RGB code. The hex code means hexadecimal consisting of sixteen values. It contains the digits from 0 to 9 and letters from A to F. For example, #RRGGBB is the hex code, where the first two values represent red, the two middle values represent green, and the last two values represent blue. We combine these three values to make different colors in HTML. #808080 is an example of a hex code representing the color Grey.

The RGB code (0, 0, 0) has the hexadecimal code, #000000 which represents black. The RGB code (0, 0, 0) means low intensity, while the RGB code (255, 255, 255) has the hexadecimal code, #FFFFFF which represents white color, means high intensity.

Syntax:

<font color="#808080"> 

HSL and HSLA Values

We use HSL and HSLA values to define the color of the text in an HTML document. HSL stands for hue, saturation, and lightness. HSLA stands for hue, saturation, and lightness with an Alpha.

Hue represents degrees from 0 to 360, which means red, 120 means green, and 240 means blue.

Saturation defines the saturation of the color. 0% illustrates black and white defines Grey, and 100% represents the full color.

Lightness also represents the percentage. 0% represents black, and 100% represents white.

For example, hsl(0, 100%, 50%) represents the red color.

We use HSLA values for defining the opacity. In HSLA, A stands for Alpha whose range is from 0 to 1, i.e., we can set the decimal value of Alpha to an integer between 0 and 1 only.

Syntax:

<font color=" hsl(60, 100%, 50%)." 

Examples of HTML Font Color

Example 1:

In this example, we are using the color name to set the color of the text.

<!DOCTYPE html>    
<html>     
<head>
    <title> Example 1 of HTML Font Color </title>    
</head>    
<body>   
<font color="purple">
<center>
    <h1> Color Name Type </h1>
    <p> This paragraph represents purple color using the color name type. </p>
</center>  
</font>     
</body>    
</html>

Output:

As you can see, the text color becomes purple.

HTML Font Color

Example 2:

This example demonstrates the use of RGB and RGBA values. We are using a <font> element in which we will use the color attribute to give the color to the element. We will also use CSS code to provide color to the text.

<!DOCTYPE html>    
<!DOCTYPE html>    
<html>     
<head>
    <title> Example 2 of HTML Font Color </title>  
    <style>
        .value1{
            width: 200px;
            height: 150px;
            border: 2px solid black;
            color: rgb(69, 82, 226);
            margin: auto;
        }
        .value2{
            width: 200px;
            height: 150px;
            border: 2px solid black;
            color: rgb(69, 82, 226, 0.6);
            margin: auto;
        }
    </style>  
</head>    
<body>   
<font color="rgb(0, 1, 0)">
<center>
    <h1> RGB and RGBA value </h1>
    <p> This paragraph represents a color using RGB value. </p>
</center>  
<div class="value1"> Using RGB value </div> <br> <br>
<div class="value2"> Using RGBA value </div>  
</body>    
</html>

Output:

The output shows colored text. The heading and paragraph get the color using the color attribute inside the <font> tag. We have also used CSS to create two <div> tags with colored text.

As you can see, <div> with class value1 shows the blue text, whereas <div> with class value2 shows the same blue text, but the text color is lighter due to the RGBA value.

HTML Font Color

Example 3:

This example illustrates the use of hex numbers in the HTML document. We will also use CSS to provide text color to the element.

<!DOCTYPE html>    
<html>     
<head>
    <title> Example 3 of HTML Font Color </title>  
    <style>
        .value{
            width: 500px;
            height: 50px;
            border: 2px solid black;
            color: #508080;
            margin: auto;
        }
    </style>   
</head>    
<body>   
<font color="#888000">
<center>
    <h1> Hex Number </h1>
    <p> This paragraph represents a color using Hex code. </p>
</center>  
</font> 
<div class="value"> Setting color using hexadecimal code. </div>    
</body>    
</html>

The output shows the heading and paragraph with the text color. Using CSS, we will also style <div> tag.

HTML Font Color

Example 4:

This example demonstrates the use of HSL and HSLA values.

<!DOCTYPE html>    
<html>     
<head>
    <title> Example 4 of HTML Font Color </title>    
</head>    
<body>   
<font color="hsla(9, 100%, 64%, 1)">
<center>
    <h1> HSL and HSLA value </h1>
    <p> This paragraph represents a color using HSL value. </p>
</center>  
</font>     
</body>    
</html>

Output:

The output shows a heading, paragraph, and two <div> elements. We will use the style as an attribute and define the property inside the element where we want to apply the color.

As you can see, the <p> tag has been given pink color using the style attribute. The <div> element shows the color applied using the HSL value. The other <div> element shows color applied using the HSLA value where A means Alpha which defines opacity. When we apply the HSLA value, the color of the text fades.

HTML Font Color

Example 5:

This example illustrates the different types of font color, which specifies the different colors of the text of the HTML document. We will use color names, hex numbers, RGB and RGBA numbers, and HSL and HSLA values.

<!DOCTYPE html>
<html>
  
<head>
    <title>
        Example 5 of HTML Font Color
    </title>
</head>
  
<body>
<div> 
    <font size="15"
          color="yellow">
          <p> This color is applied to the text using color name type. </p>
    </font>
</div>
<div> 
    <font size="15"
          color="#808000">
          <p> This color is applied to the text using hexadecimal code. </p>
    </font>
</div>
<div> 
    <font size="15"
          color="rgb(0,1,0)">
          <p> This color is applied to the text using RGB and RGBA number type. </p>
    </font>
</div>  
<div> 
    <font size="15"
          color="hsl(0, 100%, 0%)">
          <p> Font color HSL and HSLA value types are not supported by HTML5. </p>
    </font>
</div>
</body>
</html>

Output:

The output shows the different colors which are applied using different color types.

HTML Font Color

Browser Support:

It supports the following browsers:

  • Google Chrome
  • Opera
  • Mozilla Firefox
  • Safari
  • Internet Explorer