Skip to content

Instantly share code, notes, and snippets.

@arkon
Created June 30, 2016 14:54
Show Gist options
  • Save arkon/214372022df82211933f4098b1f516c0 to your computer and use it in GitHub Desktop.
Save arkon/214372022df82211933f4098b1f516c0 to your computer and use it in GitHub Desktop.
Efficient CSS selectors
1. ID, e.g. #headerClass
2. Class e.g. .promoType
3. Type e.g. div
4. Adjacent sibling, e.g. h2 + p
5. Child, e.g. li > ul
6. Descendant, e.g. ul a
7. Universal, i.e. *
8. Attribute, e.g. [type="text"]
9. Pseudo-classes/-elements, e.g. a:hover
Browsers read selectors right-to-left: #social .social-link {} is better than #social a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment