Question

Should I include 'default' styles in my stylesheet for elements, that aren't even used on my page?

For example, when I only use h1, h2, h3 and h4, do I really need to add styles for h5and h6? Or when I don't use tables on my webpage, do I need to add basic styles for then?

Of course one could say "just in case...", but on the other hand it's all data that has to be transferred.

Was it helpful?

Solution

I think this is a question of how certain you are that they'll never be used. Are you working on a site that includes a CMS and markup that you don't personally control? Can you be sure that no one, ever, under any circumstances might use an h5?

If it's a static site that only you will ever edit, they by all means, you know what you're using and what you're not, and you'll presumably carefully preview any changes before publishing, so I don't see the harm in keeping your CSS a bit leaner by removing things you're not using at all.

But if you're not sure, I think the overhead of adding a couple more lines to cover it just in case is minimal, really.

OTHER TIPS

Yes and No. You can use a normalize type css to reset all elements to a base level. But beyond that create good sections so that if and when you need to add that h6, you or whoever has inherited your files can easily find the right place to do so.

http://necolas.github.com/normalize.css/

If you don't set them, you rely on browsers' default rendering for such elements.

Here you can find the most common CSS reset scripts (so you're sure to have a consistent rendering on every browser): http://www.cssreset.com/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top