html - What's the difference between CSS id selector and CSS class selector? -


for example, can same results following 2 ways.

 <html>  <head> <style type="text/css">  p#red{color:red}    /* css id selector*/  p.green{color:green}   /* css class selector*/  </style>  </head>  <body>  <p id="red">red color</p> <p class="green">greencolor </p>  </body> </html> 

they both can give me colored text. difference between them? answer.

id's unique each element can have 1 id. each page can have 1 element id classes not unique can use same class on multiple elements. can use multiple classes on same element. more about


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -