Selectors Summary
In this lesson, we learned:
- That CSS rules consist of a selector and a declaration, and a declaration consists of a property and a value.
- That there are different types of selectors:
- Universal (
*
), which selects all HTML elements. - Type, which selects elements of a specific type, e.g.,
div
. - Class, which selects elements with a specific class, e.g.,
.group
. - Attribute, which selects elements with a specific attribute, e.g.,
[src]
. - Id, which selects elements with a specific
id
attribute, e.g.,#title
.
- Universal (
- That there are pseudo-classes, which apply styles when the state changes, e.g.,
:hover
when hovering with the mouse. - That there is specificity, which determines the priority between selectors as follows:
id
>class
>attribute
>type
>*
. - That we can group selectors by separating them with a comma, e.g.,
h1, .group
. - That we can chain selectors for greater specificity by writing them immediately after each other, e.g.,
h1#title
. - That we can select descendants by inserting a space between selectors, e.g.,
ul li
.
In the next lesson, we will understand the CSS box model, which is absolutely essential for working with CSS!
Instructions
Congratulations on completing the second CSS lesson!
Start programming for free
12/12