Site Owners Forums - Webmaster Forums

Site Owners Forums - Webmaster Forums (http://siteownersforums.com/index.php)
-   Programming General (http://siteownersforums.com/forumdisplay.php?f=44)
-   -   The Difference Between ID and Class (http://siteownersforums.com/showthread.php?t=144686)

JohnKumar 08-25-2014 10:37 PM

The Difference Between ID and Class
 
The Difference Between ID and Class

ledtubelight 08-25-2014 11:15 PM

ID, short for fragment identifier, is a beautiful attribute, but it's very easy to use them improperly.

Classes, like ID's, can also be used to in JavaScript scripts, but unlike ID's, they can be used multiple times in the same HTML document. This separation of content from presentation is what makes sites powered by CSS more robust, but some don't know the full extent to which they can use classes. Classes can not only be used more than once, but more than one can be used on an element:

johnstyle 08-26-2014 09:11 PM

ID's are unique, Classes are NOT unique
Each element can have only one ID, the same class on multiple elements.
Each page can have only one element with that ID, multiple classes can be used on the same element.


All times are GMT -7. The time now is 09:54 AM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.