If you have some experience with HTML and CSS, you will understand that you are able to apply an ID or class attribute to any HTML tag, which allows you to then specify styles for that tag via the style sheet. If you look at any well built style sheet you would usually notice the use of both ID and classes. So what is the difference?
The W3C refers to the ID tag as “a unique identifier to an element”, so in plain English what this means is an ID attribute can only be used on one element, where a class can be used on multiple elements. To give an example, you would use an id when referring to a unique element such as a specific list, however would use a class when applying a certain style to one or more objects such as multiple div’s.
One interesting feature of the ID tag that I find is not well known, is the ability to link with anchor text to a specific ID. For example if you specify your footer element with an ID called “footer”, you are able to link directly to that part of the page… Let’s take news.com.au as an example. There footer is contained within a div which has an id named ‘footer’ applied to it, so if we link to:
http://www.news.com.au/#footer
You will notice the homepage loads, but scrolls directly to the footer tag, which is the bottom of the page.