RGB Color System
"RGB" stands for Red
, Green
, and Blue
. It is a model for creating a variety of colors by combining these three primary colors.
What is RGB?
All colors in the RGB model are created by combining the three colors: Red
, Green
, and Blue
.
The intensity of each color is expressed with numbers ranging from 0 to 255.
Using RGB in CSS
In CSS, you utilize the rgb()
function to set RGB color values.
Inside the parentheses, you place the numbers for red (R), green (G), and blue (B) in sequence to represent the desired color.
/* Red text */ p { color: rgb(255, 0, 0); } /* Green text */ h1 { color: rgb(0, 255, 0); } /* Blue text */ h2 { color: rgb(0, 0, 255); }
Creating Various Colors
By adjusting the values of red, green, and blue, you can create a wide range of colors.
For instance, mixing equal parts of red and blue will produce purple.
/* Set text color to purple */ div { color: rgb(255, 0, 255); }
Setting all three colors to their maximum value of 255 results in white, and setting them all to 0 yields black.
/* White text */ span { color: rgb(255, 255, 255); } /* Black text */ a { color: rgb(0, 0, 0); }
In the RGB color system, the brightness of each color is expressed as a number between 0 and 255.
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help