Class or ID


I used to always use classes in my CSS designs. Why? They were just more widespread and kept my CSS short. Plus they prefixed a period in front, much cooler than the # symbol. But the more I work with javascript and DOM intergration, I find I’m switching over to IDs more. Since javascript doesn’t have the method getElementByClass(), I’m stuck with using getElementByID(). There are large javascript libraries, (large meaning more than 10 lines) that can add that function but for what its worth, I mind as well just redo it to use IDs instead. But now looking at templates and seeing people use exclusively IDs, it finally makes sense. I’m still using classes for everything that doesn’t need to be touched by javascript but I could see a day come where IDs will be exclusive.

openanalytics 1249 views

I'm a 35 year old UIUC Computer Engineer building mobile apps, websites and hardware integrations with an interest in 3D printing, biotechnology and Arduinos.


View Comments
There are currently no comments.

This site uses Akismet to reduce spam. Learn how your comment data is processed.