Selectors

Pick exactly the elements you want by tag, class, id, position or state.

Most CSS bugs are selector bugs: the rule is fine, but it is not reaching the element you meant.

SelectorPicks
pEvery <p>
.cardEvery element with class="card"
#menuThe one element with id="menu"
nav aAny <a> anywhere inside a <nav>
ul > liOnly <li> directly inside a <ul>
a:hoverA link while the pointer is over it
li:first-childAn <li> that is the first child of its parent
input[type="email"]Inputs whose type attribute is email

Which rule wins?

When two rules set the same property, the more specific selector wins: an id beats a class, and a class beats a tag. If they are equal, the later rule wins. Reach for classes first, as they are specific enough without being hard to override.

Edit the CSS
Preview
โ† Getting started with CSSColours and units โ†’