A brief documentation about CSS Selectors

CSS selectors are used to target the HTML elements whose property will be set. Selectors make it easy to target single/multiple HTML elements.

p{ color: black; } p->selector color->property black->value

Types for CSS selectors :

  • CSS Element Selector
  • CSS ID Selector
  • CSS Class Selector
  • CSS Grouping Selector -CSS Universal Selector

->CSS element selector :The element selector selects the HTML element by name.

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

->CSS ID selector : ID is an element which is unique in nature, ID selector selects the ID attribute of an HTML element.

#para2{
          text-align:center;
          color:green;
     }

->CSS Class selector : The class selector selects HTML elements with a specific class attribute, used with dot symbol followed by class name.

.pet{
         text-align:center;
         color:black;
       }

->CSS Grouping selector: It is used to select all the HTML elements having same style definitions. for eg.:h1,h2,p etc.

h1,h2,p{
          text-align :center;
          color:blue;
         }

->CSS Universal selector :It is a special type of selector which can select all elements of the body at once. It is denoted by star or astricks symbol.

*{color:green;
        font-size:30px;
       }