Sunday, 20 September 2015

CSS Selector

CSS Selector

CSS selectors are used to s CSS Selector elect the content you want to style. Selectors are the part of CSS rule set. CSS selectors select HTML elements according to its id, class, type, attribute etc.
There are several different types of selectors in CSS.
  1. CSS Element Selector
  2. CSS Id Selector
  3. CSS Class Selector
  4. CSS Universal Selector
  5. CSS Group Selector

1) CSS Element Selector

The element selector selects the HTML element by name.
  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4. <style>  
  5. p{  
  6.     text-align: center;  
  7.     color: blue;  
  8. }   
  9. </style>  
  10. </head>  
  11. <body>  
  12. <p>This style will be applied on every paragraph.</p>  
  13. <p id="para1">Me too!</p>  
  14. <p>And me!</p>  
  15. </body>  
  16. </html>    
  17.                                                          Output

    This style will be applied on every paragraph.
    Me too!
    And me!

No comments:

Post a Comment