in , ,

HTML RGB and RGBA Colors

HTML Colors RGB
HTML Colors RGB

HTML RGB and RGBA Colors: An RGB color value addresses RED, GREEN, and BLUE light sources.

A RGBA color value is an extension of RGB with an Alpha channel (opacity).

Defining HTML Colors

There is no special HTML color tag, as the design isn’t the main function of HTML. Coloring your site is a piece of CSS inline styling. This means you need to use the style attribute in the opening tag you wish to add HTML color to.

You may use the color property to change the color of your text, or background color to change the color of the background. Both of these properties take color names, RGB, RGBA, HEX, HSL, or HSLA values.


HTML RGB Colors Values

In HTML, a color can be determined as an RGB value, using this formula:

rgb(red, green, blue)

Each parameter (red, green, and blue) defines the force of the color with a worth somewhere in the range of 0 and 255.

This means that there are 256 x 256 x 256 = 16777216 potential colors!

For instance, rgb(255, 0, 0) is shown as red, since red is set to its highest value (255), and the other two (green and blue) are set to 0.

Another example, rgb(0, 255, 0) is shown as green, since green is set to its highest value (255), and the other two (red and blue) are set to 0.

To display black, set all color parameters to 0, similar to this: rgb(0, 0, 0).

To display white, set all color parameters to 255, similar to this: rgb(255, 255, 255).

Experiment by mixing the RGB values below:

rgb(255, 99, 71)

Example


Shades of Gray

Shades of gray are often defined using equivalent values for each of the three parameters:

Example


Thanks for reading! We hope you found this tutorial helpful and we would love to hear your feedback in the Comments section below. And show us what you’ve learned by sharing your photos and creative projects with us.

salman khan

Written by worldofitech

Leave a Reply

Swift Comments

Swift Comments

Swift Operators

Swift Operators