CSS Selectors
When we are writing some CSS, there are some important things that we have to keep in mind. Like, when we are writing CSS, we have to specify what kind of element, or a group of elements, we want to specify those rules. For example, if we want to specify a set of rules for styling some div, then we need to mention somehow, that we want to apply this set of rules, for the div element, or some element belonging to some class/id, etc.
Here comes the concept of selectors. We can use the selectors to define what are we going to apply to the set of rules. There are different types of selectors, and we are going to learn about many of those selectors. Here is a list of different types of selectors –
type CSS Selectors (name selector)
- id selector
- class selector
- Universal selector
- attribute selector
There are some more things, like –
- pseudo-class
- pseudo-elements
- grouping the selectors
- descendant combinator
- child combinator
We are going to discuss these things ahead, and as and when required, we are going to use those different types of selectors. Let’s now explore some of these selectors –