Home » HTML

HTML Colors (Color codes)

HTML Colors: Here, we are going to learn about the HTML colors, color codes, how to create color codes in HTML, etc.
Submitted by Jhanvi Tripathi, on July 28, 2019

In HTML, color codes are used for representing different colors on the webpage. These colors include the colors which we see as an everyday format that a computer can interpret and display.

Naming and remembering all colors is very difficult because each variation differs other just by a small value, therefore some color codes were introduced to make the color finding process easy. The commonly used in color codes include the Hex color-codes, the RGB and the HSL values, and HTML color names, and others, these codes are used in several websites and other software applications.

Hex-Color Codes in HTML

The most popular in the color-coding field is the Hex color codes. Here there three-byte hexadecimal numbers, and with each byte in the hex code represent the intensity of RED, GREEN and BLUE for the color respectively. The proper combination of the intensities of these colors gives the required color, the hex code of the required color.

If we assume X as a hexadecimal number, then the three-byte hex-code of color would be represented as:

#XXXXX
Where,
    The first pair of X after the hash "#", represents the RED color.
    The second pair of X represents the GREEN color of the hex code.
    And, the third pair of X represents the BLUE color of the hex-code.
#rrggbb

In the hexadecimal number system, the range of the number is from 0 to F,

HX = { 0, 1, 2 ,3 ,4, 5, 6, 7, 8, 9, A, B, C, D, E, F } so the hex-code contains the digits in the HX.

In the hex codes the values ranging from 00 to FF, where 00 is the lowest intensity for color, and FF represents the highest intensity for a color. In the hex color code, the total number of valid colors is 16,777,216 i.e. 166 color. With #000000 = Black being the first and #ffffff = White being the last.

COLORS in HTML

The white color

The white color is formed by mixing of the three primary colors and that too at their full intensities, thus the resulting Hex color code for white color would be of #FFFFFF.

The black color

The Black color is formed at the absence of any color on the display screen, and it is completely opposite to the white color, so for the black color each color is displayed at its lowest intensity and thus the Hex color code is #000000.

The Red, Green, and, Blue colors

The three primary colors in hex-code, red, green and blue, could be formed by adding the highest intensity of the desired color with the lowest intensity of the other two colors. For example,

Color name Code
Red #FF0000
GREEN #00FF00
BLUE #0000FF

An example based on HTML colors (color codes)

<html>

<head>
    <title>HTML Color code example</title>
</head>

<body>
    <h1>An example based on HTML colors (color codes)</h1>
    <div style="height:50px;width:300px;background-color:#000000"></div>
    <div style="height:50px;width:300px;background-color:#FFFFFF"></div>
    <div style="height:50px;width:300px;background-color:#FF0000"></div>
    <div style="height:50px;width:300px;background-color:#00FF00"></div>
    <div style="height:50px;width:300px;background-color:#0000FF"></div>
    <div style="height:50px;width:300px;background-color:#006969"></div>
    <div style="height:50px;width:300px;background-color:#006969"></div>
    <div style="height:50px;width:300px;background-color:#F1F1F1"></div>
    <div style="height:50px;width:300px;background-color:#F40000"></div>
</body>

</html>

Output

HTML color code example output







Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.