Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Selectors, the Cascade, and Inheritance (Summary)

In this course, you learned to:

  • Link one stylesheet to your pages, choose colors that pass a contrast check, and size text in rem.
  • Select exactly the elements you mean, by class, by their place in the tree, and by their state.
  • Predict which rule wins when several match, and fix one that loses by changing a selector.
  • Let text styles inherit, keep colors in custom properties, and find out in DevTools why a rule doesn’t apply.
  • Style a whole site from one linked stylesheet.

Rosa’s site for the Elm Street Community Garden is styled now. All three pages link one stylesheet, style.css. The text is dark green on honeydew, sized in rem. The Tab key steps through the menu, and each page’s own link is bold. On the plots page, every other row is shaded, and the free plot wins over its stripe. Every color comes from tokens in one place, and you fixed the volunteer’s three rules without !important.

Things to Remember

  • CSS fails silently. Look for the warning icon.
  • Check contrast in the color picker, not by eye.
  • Specificity comes before order. Order only breaks a tie.
  • Set text styles once on body, and let them inherit.
  • When a rule doesn’t apply, ask DevTools: does it match, did it lose, is it invalid, or does it do nothing here?

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.