Javatpoint Logo
Javatpoint Logo

HTML Color Picker

HTML Color Picker

We might have come across the fact that HTML alone can only form the skeletal structure of our web pages or websites. Even though, it can dynamically manipulate each element. Similarly, colors do play an important role with HTML. Implicitly, various tools can help us dynamically serve the color requirements and for that, we have HTML Color Picker with us. Let's proceed to learn more about it.

What is Color Picker?

HTML Color Pickers are primarily used to select and input colors. They are automatically converted into colors once submitted into the browser and then convert the input colors to a string that represents it.

How to use?

To add a color picker in an HTML page, use an <input> tag with type = 'color'.

If we want to add color picker into our HTML page, we need to use the <input> tag with specified 'color' as parameter.

Additionally, the first value can be assigned using the property value and this value needs to be kept in hexadecimal. This is because colors in HTML are represented as six-digit hexadecimal values followed by a hashtag (#). The initial two digits represent the red component, which is further followed by the green component for the next two. The last two would consist of two blue components. These three components represent the whole RGB color set. The format is thus followed by:

All of these colors can be easily mixed for getting more colors. For example, $#bdaa55 gives us a brownish shade. Although, we might also have come across these hexadecimal values while working with CSS and therefore it is tough to remember all the color codes for the same. Thus, HTML color picker is a useful tool through which we can easily input and select color into our HTML components and carry out with our creative modules.

Consider the below code which represents how the color picker lets you play with these hexadecimal numbers.

The above example demonstrates the usage of <input type = 'color'> tag. We have set the initial value as #ooooff i.e. blue.

The next task is to learn about the HSL which stands for Hue, Saturation, and Lightness. It is an important component in the color picker which lets you adjust the colors according to your requirements.

Hue: It is the degree on the color picker wheel that ranged from 0 to 360 where 0 is red, 120 is green, and 240 is blue.

Saturation: It is defined as the percentage value of shade. Example 0% is considered a shade of grey while 100% is considered a full color.

Lightness: It is also a percentage-defined color picker property. Example 0% is considered black and 100% is considered white.

Consider the below example to understand the HSL usage.


HTML Color Picker

In this example, it is quite clear how the levels of hue, saturation, and lightness of the color given above are put on to level. We have used a few CSS properties like padding to make the concept crystal clear.

Creating an HTML Color Picker

The code to create a simple color picker in HTML is as follows:

In the above HTML code, we tried to create a FORM element that will be using a color type as input. This input will create and display a simple color picker in the standard Windows mode. It will allow users to select a color of their choice. The created input type will create a text box and a button that has black color as default. Whenever we click on it, it will display a color choice for the user. The visual of the output would be looking something like this.

HTML Color Picker

We can further make it huge if we use CSS and JavaScript for rendering colors in terms of HSL. Similarly, we can opt for creating additional color pickers in the HTML while constructing our web application or website.


In this tutorial, we learned how color picker serves in the HTML and how to make use of the components it offers. We came across some fundamentals of HTML color picker. We also saw how the HSL components can work wonders for the primary colors defined in the hexadecimal formats used in the HTML color picking methodology. The HSL offers an HTML color picker a dynamic color picking offer where the user can adjust the hue, saturation, and lightness of the chosen color and specify it with mixed hexadecimal. Also, it is recommended to refer to the table book of the color components since it is quite impossible to remember all the hexadecimal codes. But with this tutorial, we can create our color picker and use it conveniently.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA