Skip to content

Instantly share code, notes, and snippets.

@josephspurrier
Last active August 29, 2015 13:55
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 josephspurrier/8780216 to your computer and use it in GitHub Desktop.
Save josephspurrier/8780216 to your computer and use it in GitHub Desktop.
CSS Style Selectors for Color
<!DOCTYPE HTML>
<html>
<style>
* {
color: white;
}
p {
color: green;
}
p span {
color: palegreen;
}
p > span {
color: gold;
}
span:last-child {
color: gray;
}
span:nth-child(4) {
color: silver;
}
span {
color: orange;
}
.class {
color: black;
}
.class2 {
color: cyan;
}
span.class {
color: pink;
}
span[style] {
color: brown;
}
#id {
color: red;
}
</style>
<body>
<p style="color: green;">
Hello <!-- Green -->
<span>and</span> <!-- Gold -->
<span class="class2 class">good</span> <!-- Pink -->
<span class="class" id="id" style="">morning</span> <!-- Red -->
<span class="class" id="id" style="color: blue;">world</span> <!-- Blue -->
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment