Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Manipulate Colors with CSS


    Defining colors can be done with hex, hsl, and rgb values. Each one works by telling browsers how to blend colors and lightness together. Let's apply these to our H1 and see how it affects the text color.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Instructor: Let's go ahead and install our h1 to be the color red. We'll add that, save it, refresh. We see that everything goes red. Whenever we use the color property, not only it's going to change the text color, it's going to affect text decorations and also be the default color for any borders that are applied.

    The # here in the color value is telling us that this is the hex value where the first two are red, the second two represent green, and the last two are blue.

    For example, this is red because red is set to the highest value FF and the other is set to the lowest value of 0Let's change this hex and say RGB (255, 00Save and refresh, and our h1 is still red.

    When we use the RGB value here, this is indicating the red, green, and blue. We'll define the intensity of each color between the values of 0and 255. Red is still 255 and our other two colors are 00giving us red.

    Finally, let's remove this RGB and do hsl(0100%,50%). Save and we still have red. Hsl stands for hue, saturation and lightness. This is another way we can define colors in CSS.

    Hue is this first one here and its degree on the color wheel from 0to 360, 0is red, 120 is green, and 240 is blue. Saturation is the second one here and is a percentage value. 0means a shade of gray and 100% is the full color. Lightness is also percentage. 0is black. 50% is inaudible lighter dark. 100% is white.

    All three of these are valid when working with values that need colors like borders or backgrounds. We can set a blue background to our h1.