Could u guys and gals who have more experience tell me what is the difference in id and class. Sometimes i see in the code of sites lots of id="something" and sometimes there is only <div class="something". What´s the purpose of "id"? I tried to search for the explanation but couldn´t find one. So can u "draw me a picture" of what "id" does. thanks in advance.
here's a quick and basic explanation: Div ID's are meant to be used only once on page ( <div id="contentshell">content here</div> ) whereas "class" can be used multiple times on the same page.
The main difference between an ID and a class is that an ID can be used to identify one element, whereas a class can be used to identify more than one. Both id and class are CSS properties and HTML attributes. They may be used to identify or classify a specific area of text, link, div, table etc.
ID is used to identify an element in a page. It is similar to the name attribute. The problem with name is that, some elements can share the same name (like options of select box), whereas ID should be unique. ID is higly important as far as JavaScript is concerned. If you want javascript to access an element in your page, then ID is used. The main use of class attribute is to apply a CSS style to a group of element. You can declare a css class and have the same style applied to any number of elements by using the class attribute of the element. It is higly important as far as page designing is concerned.