CSS Selectors
Combinators
Combinators select elements based on their relationship to other elements.
| Combinator | Example | Selects |
|---|---|---|
| Descendant (space) | nav a | Every <a> anywhere inside <nav> |
Child > | ul > li | Only direct <li> children of <ul> |
Adjacent sibling + | h2 + p | The <p> immediately after an <h2> |
General sibling ~ | h2 ~ p | Every <p> after an <h2> with the same parent |
nav a { color: white; }
.menu > li { display: inline-block; }
h2 + p { font-size: 1.2em; }