---
title: "Different ways to set the color in HTML application by CSS3"  
description: "In this article I have tried to explain how many types we can set the color in HTML application using CSS3."  
author: "Vijay Shukla"  
published: 2012-12-24  
updated: 2020-01-03  
canonical: https://www.mindstick.com/articles/1087/different-ways-to-set-the-color-in-html-application-by-css3  
category: "css-css3"  
tags: ["css-css3"]  
reading_time: 3 minutes  

---

# Different ways to set the color in HTML application by CSS3

In this article I have tried to explain how many types we can set the color in HTML [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) using CSS3.\

We can specify colors in HTML application following the different [methods](https://www.mindstick.com/articles/13060/runny-nose-remedy-methods-that-work-best) which are below:

1. Hexadecimal colors

2. RGB colors

3. RGBA colors

4. HSL colors

5. HSLA colors

##### Hexadecimal Colors:

Hexadecimal numbers are "[natural](https://yourviews.mindstick.com/view/81454/lightning-strikes-are-natural-hazards-we-must-not-look-overlook)" to computers because computers store and handle binary digits, and four binary digits make one hexadecimal digit. All browsers are supported the Hexadecimal color values, Hexadecimal color syntax are #RRGGBB:

#RRGGBB: RR is informing to Red color GG is informing to Green BB is informing to Blue.

##### RGB Colors:

It’s also [support](https://yourviews.mindstick.com/view/81072/pakistan-wants-enmity-not-support-from-india-during-coronavirus-pandemic) the all browsers, RGB is an abridgment for "Red Green Blue". RGB is a color model used on displays where red, green, and [blue light](https://yourviews.mindstick.com/story/2796/does-blue-light-harmful-to-your-eyes) are combined to make millions of colors.

Syntax: rgb (red, green, blue)

##### The following values define the same color: rgb (0, 0,255) and rgb (0%, 0%, 100%).

Above line will make the blue color because intensity of the color an integer between 0 and 255 and 255 is the full value of the blue color and red is 0(zero) and green is also 0(zero).

##### RGBA Colors:

RGBA stands for Red Green Blue Alpha, It's the extended version of RGB and through the RGBA we can make a color an abbreviation for "Red Green Blue" and with Alpha we give opacity to color, if we give value of Alpha is 0.1 it will make the color fully [transparent](https://answers.mindstick.com/qa/92940/which-platform-launched-for-transparent-taxation-in-2020-india) and if we give the 10 color will make fully opaque. RGBA color values are supported in IE9+, [Firefox](https://answers.mindstick.com/qa/95593/how-do-i-manage-firefox) 3+, Chrome, Safari, and in Opera 10+.

**Syntax:** rgba (red, green, blue, alpha).

##### HSL Colors:

HSL stands for hue, saturation, and lightness which is represents a cylindrical-coordinate representation of colors. HSL color values are supported in IE9+, Firefox, Chrome, Safari, and in Opera 10+.

**Syntax**: hsl (hue, saturation, lightness).

##### HSLA Colors:

HSLA stands for hue, saturation, lightness and alpha, HSLA Extended to HSL which is also represents a cylindrical-coordinate representation of colors but alpha make the color transparent. HSLA color values are supported in IE9+, Firefox 3+, Chrome, Safari, and in Opera 10+.

**Syntax:** hsla (hue, saturation, lightness, alpha)

##### Below is Example for all Colors:

```
<!DOCTYPE html>
<html>
<head>
<style>
.First
{
background-color:#CD853F;
}
.Second
{
background-color:rgb(205,133,63);
}
.Third
{
background-color:rgba(205,133,63,0.5);
}
.Fourth
{
background-color:hsl(20,90%,70%);
}
.Fifth
{
background-color:hsla(20,90%,70%,0.3);
}
</style>
</head>
<body style="width:210px; height: 100px;">
<p class="First">This is for <b> Hexadecimal </b> Colors.</p>
<p class="Second">This is for <b> RGB </b> Colors.</p>
<p class="Third">This is for <b> RGBA </b> Colors.</p>
<p class="Fourth">This is for <b> HSL </b> Colors.</p>
<p class="Fifth">This is for <b> HSLA </b> Colors.</p>
</body>
</html>
```

##### Below Is Output:

![Different ways to set the color in HTML application by CSS3](https://www.mindstick.com/mindstickarticle/da9ba8fb-28d1-4429-a489-9616adf7635d/images/d2b053bd-1279-4aa9-b4e7-c3977ba6dd4b.png)

\

---

Original Source: https://www.mindstick.com/articles/1087/different-ways-to-set-the-color-in-html-application-by-css3

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
