Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Book said don't use CSS IDs, use class instead but what about when Javascript? Reply To: Book said don't use CSS IDs, use class instead but what about when Javascript?

#182364
__
Participant

Classes vs. IDs: I generally have very few IDs on a page, if any. About the only thing I use them for is document hashes (i.e., to be able to link to a specific item on the page). I use class names as styling hooks, and either class names or data-* attributes as JS hooks.