id or class? Which to use and why
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. They both hold great purpose and are very useful when creating a web page.
An id may be used just once, but holds great purpose. Using an id seperate from the classes is helpful when laying out the stylesheet and also within the html document. Since ids should be used sparingly, may be used once to identify large segments of the site or important information, link, etc., it makes for an easier to find area within the CSS or HTML document.
As for a class, it is somewhat the same as id, but also different. Unlike an id, a class may be used as many times as needed. Either one or hundred. Classes are used to classify areas with a specific property. For example; giving an area of text underline or color.
However, id and class have many similarities. Both are used to strengthen web pages and give better overall designs to sites. As well, the same CSS properties used for id may be used for classes.
The use of both id and class may be conducted on the same page. Doing this will diversify the content and create an easier to read html and css source document, lowering the time needed to edit each file.
