About this lesson
Download this lesson’s exercise file.Colors
There are three main ways to use color in CSS.
When to use
Any time you want to use colors in your CSS, you'll use one of these three ways.
The first way to use color in CSS is to just name the color. Like red. Or blue. Or whatever.
That's not a very good way because you can't really use different shades of colors.
Instead, use either hex color codes, or RGB color codes (hint: use hex).
Hex color codes look like this:
You can find the codes for the color you want by using a hex color code picker website.
RGB color codes look like this:
The first number is your red number, the second number is your green number, and the third number is your blue number.
Like hex color codes, find RGB codes with a color picker website.
You'll always want to use Hex codes over RGB codes.
Hints & tips
- There are 3 ways to use color in CSS.
1. Name the color, like red.
2. Use RGB values, like rgb(255,0,0).
3. Use hex color codes like #cccccc.
- Always use hex, it's the standard method
Lesson notes are only available for subscribers.