Is it better to limit the HTML to few classes and ids and keep the size of the HTML low OR is it better to use a lot of nested CSS instead.
These are the advantages I can think of for both.
Advantages of using few nested CSS rules:
- Smaller CSS file
- Efficient targeting of elements inside the CSS
- Possibly quicker rendering times in the CSS (not sure about this)
Advantages of using a lot of nested CSS rules:
- Small HTML size throughout the site
- CSS gets cached
- Better organization of code (I’m using LESS)
Thanks.
I’d argue large CSS over large HTML any day. Your CSS will be cached, so your pages will load much faster with smaller HTML. More classes does mean more flexibility, but you’d be surprised at how much you can accomplish using CSS selectors. The only time I see bulking up the HTML as something that is useful is for SEO; see microformats for an example of what I mean.
Accuracy should not be a question whatsoever (even if you factor in human error, you should be able to immediately catch your mistake). As far as speed goes, I doubt it has an effect on performance. Keep in mind all the rendering is done client-side so you don’t need to worry about the server doing any more work because of more complex CSS selectors.