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?
September 9, 2014 at 4:34 am
#182326
Participant
The book (which book?) probably meant that it’s OK to give IDs to elements, and to target them with JavaScript, but to not use IDs for styling. In other words, avoid calling any ID in your CSS file because of their high specificity weight.
Other than that, the use of IDs are fine, and it’s OK to call them in your JavaScript files because specificity is not an issue there.