Professional Documents
Culture Documents
Bing
CSS selectors are patterns used to select the HTML elements you want to style. Here are some of the main types
of CSS selectors:
1. Element Selector: Selects HTML elements based on the element name. For example, p { text-align:
center; color: red; } selects all <p> elements and makes the text color red and aligns the text to the center.
2. ID Selector: Uses the id attribute of an HTML element to select a specific element. The id of an element
should be unique within a page. For example, #para1 { text-align: center; color: red; } selects the
HTML element with id=“para1”.
3. Class Selector: Selects HTML elements with a specific class attribute. For example, .center { text-align:
center; color: red; } selects all HTML elements with class=“center”.
4. Universal Selector: The universal selector (*) selects all HTML elements on the page.
5. Grouping Selector: Selects all the HTML elements with the same style definitions.
Each of these selectors provides a different way to target and style elements on a web page. They can be used
individually or combined to create more specific selections…