Skip to content

Instantly share code, notes, and snippets.

@peterjwest
Last active March 4, 2016 13:47
Show Gist options
  • Save peterjwest/5100474 to your computer and use it in GitHub Desktop.
Save peterjwest/5100474 to your computer and use it in GitHub Desktop.
CSS Specificity

Some html:

<a id="redLink" class="red link" href="#">Click me!</a>

CSS specifity, low to high:

a { color: red; }
body a { color: red; }
a.red { color: red; }
body a.red { color: red; }
a.red.link { color: red; }
body a.red.link { color: red; }
a#redLink { color: red; }
body a#redLink { color: red; }
body a#redLink.red { color: red; }
body a#redLink.red.link { color: red; }
style="color: red;"
a { color: red  !important; }
body a { color: red  !important; }
a.red { color: red  !important; }
body a.red { color: red  !important; }
a.red.link { color: red  !important; }
body a.red.link { color: red  !important; }
a#redLink { color: red  !important; }
body a#redLink { color: red  !important; }
body a#redLink.red { color: red  !important; }
body a#redLink.red.link { color: red  !important; }
style="color: red !important;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment