Created
August 25, 2012 16:58
-
-
Save byrichardpowell/3467893 to your computer and use it in GitHub Desktop.
Selectors should be 3 or less levels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* BAD: The following selectors should be avoided if possible */ | |
.one .two .three .four { /* styles */ } | |
.one ul li a { /* styles */ } | |
.one ul a:hover { /* styles */ } | |
.one ul li:first-child { /* styles */ } | |
/* BAD: Pre-processed nested selectors */ | |
.one { | |
.two .three.four { /* styles */ } | |
ul li a { /* styles */ } | |
} | |
/* GOOD: No more than 3 levels deep */ | |
.one .four { /* styles */ } | |
.one li a { /* styles */ } | |
.one a:hover { /* styles */ } | |
.one li:first-child { /* styles */ } | |
.one a:hover { /* styles */ } | |
/* ACCEPTIBLE: Discretion is advised */ | |
/* This is 4 levels, but the extra specificity may be preferable */ | |
.one li a:hover { /* styles */ } | |
.one li a.active { /* styles */ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment