Webbers Corner

Full Version: ID and Class?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This may seema strange question but when looking at different peoples source codes for websites some us class and some use id to label divs.

well what is the difference between them and can one do something the other can't?

dave.
An ID name can only be applied to one element on a page, the same class name can be applied to any number of elemnts on a page. Classes are very useful for identifying types of content of similar items. For instance, you may have a news page that contains the date of each story. Rather than giving each date a separate ID, you could give all of them a class name of date
ah, that explains it!

thanks for clearing that up.
Reference URL's