Selectors in Css

Selectors in Css

Table of contents

Css selectors are use to find the element whose property will be set css selectors are used to target html elements selectors make it easy for us to easily target single/multiple HTML elements in markup

there are 4 kind of selectors

  1. css element selector
  2. css id selector
  3. css class selector
  4. the css grouping selector

so there are way how to target each one of them

  1. element selctor is simple where we can just hit the particular tag and add the instruction to it and it will change p{ color: red; }

  2. id selector is one where we can target particular elemnets and can give command to it and we can do so by just declaring id= "id_name" it is unique

    redElement {

                color: red;
             }
    
  3. class selector it is most used one and by which we can target multiple tags just by declaring them into a class we can also give two class and perform action on to it we target them by simple (.) and class will be called .navigation {

            background_color: black;
        }
    

also ex

.navigation list_item{ align_item: center; color: blue; }

  1. grouping selectors helps us to select multiple tags in one line it self by just adding a (,) and we can declare the instruction accordingly
    footer,span {
                background_color: pink;
             }