Understanding HTML Colors: names, RGB, HEX

    HTML-Logo

    In HTML, colors can be specified in three different ways: by color names, HEX values, or RGB values. Let's delve into each of these methods:

    Color Names

    HTML supports 140 standard color names. These color names are case-insensitive and they are easy to understand and use. Here are some examples:

    <p style="color:Red">This is a red text.</p>
    <p style="color:Blue">This is a blue text.</p>
    <p style="color:Green">This is a green text.</p>

    output:

    This is a red text.

    This is a blue text.

    This is a green text.

    The drawback with using color names is that your choices are limited to those predefined 140 colors.


    HEX Values

    HEX values specify colors using hexadecimal values. A HEX value is a six-digit combination of numbers and letters defined by its mix of red, green, and blue (RGB). Each of the three colors can have values from 00 to FF. For example:

    <p style="color:#FF0000">This is also a red text.</p>
    <p style="color:#0000FF">This is also a blue text.</p>
    <p style="color:#008000">This is also a green text.</p>

    output:

    This is also a red text.

    This is also a blue text.

    This is also a green text.

    HEX values offer more than 16 million color options, allowing for greater precision in your color selection.


    RGB Values

    RGB values specify colors using the Red-Green-Blue system. In this system, colors are defined by specifying the level of Red, Green, and Blue light needed to achieve the desired color. Each of these colors can have a value from 0 to 255. Here's an example:

    <p style="color:rgb(255,0,0)">This is red text again.</p>
    <p style="color:rgb(0,0,255)">This is blue text again.</p>
    <p style="color:rgb(0,128,0)">This is green text again.</p>

    output:

    This is red text again.

    This is blue text again.

    This is green text again.

    Like HEX values, RGB also provides more than 16 million possible colors.


    Understanding Color Values

    In both HEX and RGB, the first value stands for Red, the second for Green, and the third for Blue. The higher the value, the more of that color is included.

    For example, in HEX color #FFFFFF, or in RGB color rgb(255,255,255), all colors are at their highest levels, which combines to make the color white. If all colors are at their lowest level, as in #000000 or rgb(0,0,0), the resulting color is black.