All About Selectors IN CSS

All About Selectors IN CSS

CSS selector is used to select HTML elements.

Whenever you have to apply something for a particular element in HTML with the help of a CSS selector you can apply the changes.

We can divide CSS Selector into five different categories.

1) Simple Selectors: In Simple selector we can include elements based on name, id, and class.

Example for Simple Selectors :

 p{
            background-color: black;
            color: white;
        }

2)Pseudo-class Selectors: In Pseudo-class Selectors we include elements based on some certain state.

3) Pseudo-element Selectors: In Pseudo-elements Selectors we include elements to style a particular part of the element.

4)Combinator Selectors: In Combinator Selector we include some specific relationship between two selectors.

Attribute Selectors: In Attribute Selectors, we include elements based on some attribute or attribute value.