What is Selectors?

What is Selector used for?

A selector is one of the properties of the object that we use along with the component configuration. A selector is used to identify each component uniquely into the component tree, and it also defines how the current component is represented in the HTML DOM.

The Selector is a Three types

  • Simple selectors (select elements based on name, id, class)
  • Combinator selectors(select elements based on a specific relationship between them)
  • Pseudo-class selectors(select elements based on a certain state)
  • Pseudo-elements selectors¬†(select and style a part of an element)
  • Attribute selectors(select elements based on an attribute or attribute value)

Types of Selectors in CSS

CSS selector selects the HTML element(s) for styling purpose. CSS selectors select HTML elements according to their id, class, type, attribute, etc.

There are many basic different types of selectors.

  • Element Selector
  • Id Selector
  • Class Selector
  • Universal Selector
  • Group Selector
  • Attribute Selector

HTML code: Consider the sample code to understand selectors and their uses in a better way.