Lecture

RGB Color System

"RGB" stands for Red, Green, and Blue, the three primary colors mixed together to create a variety of colors.


What is RGB Color?

All colors can be created by mixing Red (R), Green (G), and Blue (B). Each color's brightness is expressed as a number ranging from 0 to 255.


Using RGB in CSS

In CSS, you use the rgb() function to set RGB color values.

Put the numbers representing the intensity of Red (R), Green (G), and Blue (B) in the parentheses in that order to express 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 example, mixing equal amounts of Red and Blue produces purple.

/* Set text color to purple */ div { color: rgb(255, 0, 255); }

Setting Red, Green, and Blue all to the maximum value of 255 results in white, while setting them all to 0 produces black.

/* White text */ span { color: rgb(255, 255, 255); } /* Black text */ a { color: rgb(0, 0, 0); }
Mission
0 / 1

In the RGB color system, the brightness of each color is represented by a number between 0 and 255.

True
False

Lecture

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help