CSS selectors are patterns used to select and target specific HTML elements that you want to apply styles to. There are several types of selectors, each with its own way of targeting elements. Here are some common CSS selectors:
1. **Tag Selector**: Selects all elements of a specific tag. For example, `p` selects all `<p>` paragraphs.
2. **Class Selector**: Selects elements with a specific class attribute. It is denoted by a period (.) followed by the class name. For example, `.highlight` selects all elements with the class "highlight."
3. **ID Selector**: Selects a single element with a specific ID attribute. It is denoted by a hash (#) followed by the ID name. For example, `#header` selects the element with the ID "header."
4. **Universal Selector**: Selects all elements on the page. It is denoted by an asterisk (*). For example, `*` selects all elements.
5. **Descendant Selector**: Selects elements that are descendants of another element. It is denoted by a space between two selectors. For example, `ul li` selects all `<li>` elements that are descendants of `<ul>` lists.
6. **Child Selector**: Selects direct children of an element. It is denoted by a greater than sign (>). For example, `ul > li` selects all `<li>` elements that are direct children of `<ul>` lists.
7. **Adjacent Sibling Selector**: Selects an element that directly follows another element. It is denoted by a plus sign (+). For example, `h1 + p` selects the `<p>` element that directly follows an `<h1>` heading.
8. **Attribute Selector**: Selects elements based on their attribute values. It is denoted by square brackets and can have various attribute matching options. For example, `[type="text"]` selects all elements with `type="text"`.
9. **Pseudo-classes**: Selects elements based on their state or position. Some common pseudo-classes include `:hover` (selects when hovering over an element), `:first-child` (selects the first child element), and `:nth-child(n)` (selects the nth child element).
10. **Pseudo-elements**: Selects parts of an element, such as the first line or first letter. They are denoted by double colons (::) or a single colon (:), depending on the pseudo-element.
These are just some of the CSS selectors available, and you can combine them to create more specific and targeted style rules for your HTML elements.