Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRushabha Jain
Full Stack JavaScript Techdegree Student 11,141 PointsNaming convention of classe's and id's
While selecting and manipulating element in the javascript should we add more class which starts with js-* in the html page and also the id with the same naming convention?
1 Answer
Jamie Reardon
Treehouse Project ReviewerYou should avoid adding extra markup to your html if it's purely for manipulating that element with JS.
You should use the (if exists) classes that you have defined for the page when using those with css.
Your naming conventions should clearly communicate describing what the element is or does etc. You can find many naming convention types but it simply comes down to that.
Always remember the audience that may view your code, other developers. If you had prefixing classes that had js- at the beginning, other users may think that the element is purely JS driven, and has no styling attached for example.