Skip to content

Instantly share code, notes, and snippets.

@jayontraps
Created April 10, 2012 11:12
Show Gist options
  • Save jayontraps/2350533 to your computer and use it in GitHub Desktop.
Save jayontraps/2350533 to your computer and use it in GitHub Desktop.
CSS3 selectors
/**
* CSS3 selectors
*/
p:first-child {
color: blue;
}
p:last-child {
color: red;
}
p:nth-child(2) {
color: green;
}
p:nth-child(3n+1) {
font-style: italic;
color: black;
}
p:nth-last-child(2) {
color: olive;
}
img[src*="ogo"] {
border: 1px solid red;
margin: 0 20px;
}
div:first-of-type {
border: 1px solid cyan;
padding: 5px;
}
article:empty {
background: lightgray;
width: 100px;
height: 20px;
margin: 10px 0;
}
p:not(.tac) {
font-weight: bold;
text-decoration: underline;
}
article ~ div {
background: yellow;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment