Skip to main content

HTML HEX Colors

By SamK
0
0 recommends
Topic(s)

A hexadecimal (HEX) color is defined using the format: #RRGGBB, where the RR (red), GG (green), and BB (blue) are hexadecimal integers, which determine the color components.

HEX Color Values

In HTML, a color can be defined using a hexadecimal value with the format:

color: #rrggbb;

Where rr (red), gg (green), and bb (blue) represent hexadecimal values ranging from 00 to ff (equivalent to decimal 0-255).

For instance, #ff0000 appears as red, as the red component is set to its maximum value (ff), while the green and blue components are set to 00.

Another illustration: #0000ff is rendered as blue, as the blue component is set to its maximum value (ff), while the red and green components are set to 00.

To represent black, set all color parameters to 00, such as: #000000.

To represent white, set all color parameters to ff, such as: #ffffff.

Some  examples

The below CSS code will show the paragraph element in red color.

p { 
    color: #ff0000;
}

The below code will show the paragraph element with a blue background-color.

p {
    background-color: #0000ff;
}

The below CSS code will show the paragraph element in green color.

p { 
    color: #00ff00;
}