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 trial

CSS CSS Basics (2014) Basic Selectors Descendant Selectors

classes, IDs etc

So far classes and IDs seem to be getting used for almost everything, is this common? or would this in turn slow down the performance when a site increases in size?

1 Answer

Austin Whipple
Austin Whipple
29,725 Points

I think you'd have to add a ridiculous number of IDs and classes to increase the data size enough to slow down a site. HTML is pretty lightweight overall, so normal usage of IDs and classes (even adding a few classes to most elements on a page) shouldn't negatively impact performance.

Some important things of note here: First, HTML 5 has added a lot of semantic elements such as header, footer, article, etc., so some need for class names has been reduced (using header instead of <div class="header"> for instance). Second, IDs should be unique on the page and are often reserved for functionality more than design. If you have multiple elements on a single page with the same ID, your HTML is no longer valid.