CSS selectors are used to "find" (or select) the HTML elements you want to style.
We can divide CSS selectors into five categories:
The id of an element is unique within a page, so the id selector is used to select one unique element!
#para1 {
text-align: center;
color: red;
}
The class selector selects HTML elements with a specific class attribute.
To select elements with a specific class, write a period (.) character, followed by the class name.
.center {
text-align: center;
color: red;
}
The universal selector (*) selects all HTML elements on the page.
* {
text-align: center;
color: blue;
}
The grouping selector selects all the HTML elements with the same style definitions.
Look at the following CSS code (the h1, h2, and p elements have the same style definitions):