The Most Important CSS Selectors


/* https://code.tutsplus.com/tutorials/the-30-css-selectors-you-must-memorize--net-16048 */

/* every element on page */
* {
border: 1px solid lightgrey;
}

/* element */
li {
text-decoration: underline;
}

/* class */
.hello {

}
/* id */
#name {

}

/* Descendant Selectors - example only affects links in an unordered list */
li a {
color: red;
}

/* Adjacent Selectors - examples only affects unordered lists that follow a h3 */
h3 + ul {
border: 4px solid red;
}

/* Attribute Selectors - examples selects only links that include the given url - can be used for any attribute like images */
a[href="http://www.google.com"] {
background: blue;
}

input[type="text"] {
background: orange;
}

/* nth of type */
ul:nth-of-type(3) {
background: purple;
}

li:nth-of-type(even) {
background: green;
}