Class vs ID
- The difference between ID and class is that an ID selector can be called only once in a document, while a class selector can be called multiple times in a document.
- The second difference is that ID can be called by Javascript's getElementByID function.
- There is no hard rule on when to use ID and when to use Class.
- Use class as much as possible for maximum flexibility, with the only exception being when you want to use Javascript's getElementByID function, in which case you need use ID.
- Class and ID names are both Case Sensitive. For example, .classabc and .ClassABC are two different classes.
No comments:
Post a Comment