CSS Selectors

CSS Selectors

Let us understand what CSS selector is. But, before jumping into CSS selector we have to know what exactly CSS is.

CSS

CSS (Cascading Style Sheets) is a stylesheet language which we use to style an HTML document. With the help of CSS we can describe how each element should render on the web page.

CSS Selectors

Now let's move to CSS Selectors. First and the most important step of learning & understanding CSS is targeting and if we know how to target an element in the HTML file then our job of beautifying/styling our web page becomes easy. And for targeting we need to know about selectors.

Universal Selector

Individual Selector

Class and Id Selector

And Selector (chained)

Combined Selector

Inside an element Selector

Direct Child Selector

  • It is used to select tags that are direct children of the first element. " > " is used between the parent tag and child tag.
  • Have a look at below example for better understanding.

Sibling ~ or + Selector

Before and After Pseudo Selector

Thanks for reading. Happy Learning!!

Did you find this article valuable?

Support Imbeshat's blog by becoming a sponsor. Any amount is appreciated!