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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -