Most common CSS selectors
Child Selector
The 'child selector' (>) will select a direct descendant that matches, but only go one level deep.
Given the following HTML:
<div class="outer">
<div class="inner">
<div class="very-inner"></div>
</div>
</div>
// targets inner, but not very-inner
.outer > div {
}
Descendent Selector
The 'descendent selector' ( i.e. a space) will select any descendent that matches, infinite levels deep.
// targets both inner and very-inner
.outer div {
}
More common CSS selectors
*selects all elements*, *::before, *::afterselects all elements and pseudoelements#an-idselects the single element with that id.a-classselects all of the elements with that classX, Yselects elements that match selector X or selector YX Yselects the elements matching Y that are descendants of X- tag name: selects the elements of that tag
a:visiteda:linkX:hoverX + Y: It will select only the specified element that immediately follows the former specified element.X > Y: direct descendant, childX ~ Y: general sibling selector