Skip to content

Instantly share code, notes, and snippets.

@qmmr
Last active December 12, 2015 02:48
Show Gist options
  • Save qmmr/4701396 to your computer and use it in GitHub Desktop.
Save qmmr/4701396 to your computer and use it in GitHub Desktop.
CSS selectors - recap
/* attribute selectors */
/* <li class=""> or <li class> or <li class="foo"> */
li[class] { background-color: gray; }
/* <li class="red"> exactly red */
li[class="red"] { background-color: red; }
/* <li class="some other classes green"> targets space separated list of values */
li[class~="green"] { background-color: green; }
/* <li class="blue-text"> target followed by hyphen */
li[class|="blue"] { background-color: blue; }
/* <li class="bunch of classes and yellowish"> targets yellow */
li[class*="yellow"] { background-color: yellow; }
/* <li class="bunch of classes and brownish"> starts with brown */
li[class^="brown"] { background-color: brown; }
/* <li class="bunch of classes and pinkish"> end with ish */
li[class$="ish"] { background-color: pink; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment