Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

Summary

In this lesson, we learned that:

  • The color property sets the color of the text, and background-color the color of an element's background. color is inherited. background-color is not, but backgrounds are transparent by default, so the background of the element around them shows through.
  • The background of body covers the whole browser window.
  • CSS knows 148 named colors, such as green, linen or tomato.
  • An RGB color mixes red, green and blue light, each from 0 to 255: rgb(71, 105, 88).
  • A hex color writes the same three numbers in the hexadecimal system, two characters each: #2a231b. When both characters of each pair are the same, we can use the short form: #fff.
  • An HSL color is described by its hue (0 to 360° on the color wheel), saturation and lightness: hsl(150, 19%, 20%). We get a lighter or darker version of a color by changing its lightness.
  • An alpha makes a color transparent, from 0 (transparent) to 1 (opaque), for example rgba(71, 105, 88, 0.2), hsla(150, 19%, 35%, 0.2) or #47695833. Decimal numbers are written with a dot.
  • The opacity property makes a whole element see-through, including its text and everything inside it, while an alpha affects only one color.
  • Text must contrast with its background so that it's easy to read.

Next comes a small project, in which you'll try out everything from the first three lessons on your own: you'll give a café's menu its colors. Then, in the lesson Text and Fonts, we will choose fonts for our page and set the size, weight, line spacing and alignment of the text.

Instructions

  1. 1

    Congratulations on completing the lesson on colors! The editor contains your page as it looks now, and we will continue with it in the lesson Text and Fonts, after the small project. Try changing the colors to your liking.

Back

9/9

  1. 1. Named Colors
  2. 2. Quiz: Named Colors
  3. 3. Background Color
  4. 4. RGB Colors
  5. 5. Hexadecimal Colors
  6. 6. HSL Colors
  7. 7. Transparent Colors
  8. 8. Opacity
  9. 9. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.