Advanced Selectors
I assume you already know how to style stuff by its id
, class
, or element
.
Goals
- Headlines (
<h1>
) followed by a subhead (<h2>
) shouldn't have space between them.
- Subheads that follow a headline should have a red line (
border-bottom
) under them.
- Subheads elsewhere should have normal margin and no bottom border
- Italics
<i>
inside of h1 or h2 should be blue. But not elsewhere.
- In the list, even items should have a yellow background.
Notes
.a + .b
is an adjacent selector. It matches elements with a class b
that are right after elements with a class .a
.
nth-child
is pretty cool. You should read about it.