ids can be applied to only one item on a page
Here's how we hook an id attribute to an element:
id="id-div"
Here's how the CSS is applied to the element:
div#id-div{ background-color:lightblue; }
Here's what it looks like:
classes can be applied to several items to a page
Here's how we hook a class attribute to an element:
class="my-list"
li.my-list{ background-color:pink; }
Compounds selectors allow us to use more then one selector for a set of rules. The selectors must be separated by commas.
div#new-div,li,new-list{ background-color:lavender; }
The child selector allows us to access the elements that are immediately inside the current element.
ul.my-kids > li{ background-color: lightgreen; }
The descendant selector selector allows us to hook to an element at any depth inside the current element.
div.grandkids li{ background-color: lightsalmon; }
we can apply multiple classes by placing them in the class attribute with a space between each.
Here's how we hook a multiple classes to an element:
class="add-border add-background"
.add-background{ background-color: #antiquewhite; } .add-border{ border-color: #000; }