19 Learning Advanced CSS Selectors
HTML elements enable web page designers to mark up a document's structure, but beyond trust and hope, you don't have any control over your text's appearance. CSS changes that. CSS puts the designer in the driver's seat. — Håkon Wium Lie
This chapter covers
- Learning the powerful ID and universal selectors
- Leveling your style game with the descendant, child, and sibling selectors
- Targeting your styles by combining two or more selectors
- Becoming a style master by understanding CSS inheritance, cascading, and specificity
On the surface, CSS seems like a simple topic: You apply values to some properties, combine them into a rule, and then apply that rule to a page element. Repeat a few more times, and voilà: your page is beautiful. But the apparent simplicity of CSS is only skin-deep. Underneath the straightforward implementation of declarations and rules are obscure caves of complexity and unfathomed depths of dynamism. This chapter serves as an introduction to this hidden world, which is home to some of the most powerful and practical CSS concepts.
Working with ID Selectors
In Chapter 7, I introduced you to CSS selectors, which enable you to specify the page object you want to style:
selector { property1: value1; property2: value2; ... }