Summary
In this lesson, we learned that:
- The
colorproperty sets the color of the text, andbackground-colorthe color of an element's background.coloris inherited.background-coloris not, but backgrounds are transparent by default, so the background of the element around them shows through. - The background of
bodycovers the whole browser window. - CSS knows 148 named colors, such as
green,linenortomato. - 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
opacityproperty 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
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.