DOM hierarchy pseudo-classes allow you to style specific elements based on where they fall in the hierarchy and what type of elements they are. You can also use :nth-child
to target custom element patterns, like every other element (odd or even).
Very useful lesson but the -n + 4 confuses me. The -n indicates that the element 0 is included in the selection? But how is it possible if the 0th element doesn't exist?
If it targets an element that doesn't exist, it is just skipped over - that's how all CSS selectors work. If you have a selector that targets an element that doesn't exist, no warnings or errors are thrown, it is just ignored.