What\'s the difference between
IDs are unique. Classes aren't. Elements can also have multiple classes. Also classes can be dynamically added and removed to an element. Anywhere you can use an ID you could use a class instead. The reverse is not true. The convention seems to be to use IDs for page elements that are on every page (like "navbar" or "menu") and classes for everything else but this is only convention and you'll find wide variance in usage. One other difference is that for form input elements, the In years gone by IDs were also preferred because they're easily accessible in Javascript (getElementById). With the advent of jQuery and other Javascript frameworks this is pretty much a non-issue now.
element references a field by ID so you need to use IDs if you're going to use
. is an accessibility thing and you really should use it.