Class vs ID
Class
.classelement {color:red;} <div class="classelement">text here<⁄div>
a class can be used multiple times
ID
#IDelement {color:red;} <div id="IDelement">text here<⁄div>
ID can only be used once
IDs carry a heavier weight in determining styles
IDs can be more specific
This example shows how a links can be defined within an ID only.
<style> #testid {background:#efefef;;} #testid a{font-weight:bold;color:navy;text-decoration:none;} #testid a:hover{color:green;background:yellow;text-decoration:underline;} <⁄style> <div id="testid"> <a href="#">Link inside testid ID<⁄a> <⁄div> <a href="#">Link outside ID<⁄a>
Link inside testid ID (redefined A link)
Link outside ID (base A link)