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

Page Colors

Now the colors of the whole page. As in the CSS course, we give them to body: its background covers the whole window, and the color of its text is inherited by all the elements inside it, unless they have a color of their own.

Pure black text on a white background is very sharp. Many websites soften it: a background with a hint of color and very dark gray text instead of black. We'll take the gray called stone, a warm gray with a touch of brown that goes well with orange (slate, for example, is bluish):

Black text on a white background

Stone 800 text on a stone 50 background

<body class="bg-stone-50 text-stone-800">

The heading, the link and the badge keep their own colors: a class on an element beats a color inherited from its parent, as you know from the CSS course.

Less important text, such as Tiger's age, is often a lighter gray, so that the main text stands out: text-stone-500. That's as light as text should go on a light background: stone-400 on stone-50 is already hard to read.

Instructions

  1. 1

    Add the class bg-stone-50 to the body element.

  2. 2

    Add the class text-stone-800 to body too. Look at the preview: all the text on the page is now dark gray, except the elements that have a color of their own.

  3. 3

    Add the class text-stone-500 to the paragraph with Tiger's age ("2 years · tabby").

Back

4/12

  1. 1. The Color Palette
  2. 2. Shades
  3. 3. Quiz: Shades
  4. 4. Page Colors
  5. 5. Transparent Colors
  6. 6. Font Size
  7. 7. Font Weight
  8. 8. Quiz: Font Weight
  9. 9. Line Height and Alignment
  10. 10. Letter Spacing and Case
  11. 11. Font Family and Underline
  12. 12. Summary
Next

Try it yourself

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