Skip to content

Instantly share code, notes, and snippets.

@rhatano
Created April 7, 2012 23:02
Show Gist options
  • Save rhatano/2332712 to your computer and use it in GitHub Desktop.
Save rhatano/2332712 to your computer and use it in GitHub Desktop.
Well to do that, you simply combine the two types of selectors.
Say you had some HTML like this;
<h1>Example</h1>
<h1 class="first">This is my first heading</h1>
<p class="first"> This is my first paragraph</p>
<h2 class="second">This is my second heading</h2>
<p class="second"> This is my second paragraph</p>
.first {
[some css] /*This would style the elements with the class value "first"*/
}
.second {
[some css] /*This would style the elements with the class value "second"*/
}
However:
h1.first {
[some css] /*This would only style the h1 element with the class value "first"
}
This is useful because it allows you to be more specific in how you identify elements in your html, and also
allows your CSS to be shorter with less redundant code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment