26. What is the difference between id and class?
An id identifies a particular element and should be unique within a document. A class represents membership in a reusable group and can be assigned to multiple elements.
Key Takeaways
- Use id for unique document identity.
- Use classes for reusable grouping and styling or scripting hooks.
Knowledge Check
Which is intended to identify a unique element within a document?