RGB/RGBA
Learn about RGB/RGBA colors.
We'll cover the following
RGB colors
We can use the rgb()
functional notation to calculate the color
from its RGB notation as an alternative to hex colors.
We use a list of three numeric values ranging from 0
to 255
. The first is our red
value, the next is our green
value, and the last is our blue
value.
For example:
color: rgb(255, 255, 255); /* white */
color: rgb(0, 0, 0); /* black */
color: rgb(255, 0, 0); /* red */
color: rgb(34, 139, 34); /* forest green*/
We can use the rgba()
functional notation to adjust the opacity. With RGBA, we add a fourth value. The value is a number ranging from 0
(completely transparent) to 1
(completely opaque).
For example:
p {
color: rgba(0, 255, 255, .5);
}
Example
Get hands-on with 1400+ tech skills courses.