what is Selectors in CSS?

what is Selectors in CSS?

What is the Selectors

  • CSS Selectors are used to Select the content you want style

  • Selectors are part of CSS Rule set.

  • css selectors Select HTML element According to its id,class,Tag, Type ect.

Every Css rule the general Pattern

``` selector { key: value; }


**Types of Css Selectors**
Where we have selectors (h2,p, form etc.) and a Declaration block ({}) where we declare
our styles. The Property could be **background-color, font-size, text-size** and the value
of the property could be **red, 20px , align-center** etc.

## Types are Selectors##


1. **Universal Selectors**
The universal selector select all the element 


```* {  
   color: red;  
   font-size: 20px;  
}
  1. Element Selectors

  2. the element selectors select the HTML element by name.

p{  
    text-align: center;  
    color: blue;  
}
  1. Id Selectors

  2. the id selector selects the id attribute of an HTML element to select the specific element.

  3. An id is always Unique within the page so it is chosen to select a single, unique Element.

  4. it written with a (#)hash character, follow by the id of the element.

```#id {
text-align: center;
color: blue;
}


4.**Class Selectors**

- the class selector select the HTML Element with specific class attributes
- it is used with (.)period character

.className {
text-align: center;
color: blue;
}


5.**Group selectors**

- the grouping selector is used to select  all the elements with the same style definations.
-Groupping selector is used to minimize the code. Commas are used to seprate each selectors in grouping.

h1,h2,p {
justify-content:center; color: blue;
} ```

Conclusion

  • so this was the all about css selecters, there are many css element selectors. you will just go on official docs and know more about css selectors.