Skip to content

Instantly share code, notes, and snippets.

@lafikl
Created November 22, 2012 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lafikl/4131844 to your computer and use it in GitHub Desktop.
Save lafikl/4131844 to your computer and use it in GitHub Desktop.
CSS specificity example
ul li a {
color: red;
}
.item {
color: blue;
}
/* item will win! */
<ul>
<li> <a href="#">Home</a> </li>
<li> <a class="item" href="#">About</a> </li> /* link color will be BLUE */
<li> <a href="#">Foo</a> </li>
</ul>
ul#nav li a {
color: red;
}
.item {
color: blue;
}
<ul id="nav">
<li> <a href="#">Home</a> </li>
<li> <a class="item" href="#">About</a> </li> /* color will be red */
<li> <a href="#">Foo</a> </li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment