< Back
Page 6 of 6
Like this article? We recommend
Summary
In this article, I’ve listed several common misuses of the CSS technology. While it’s hard to recover from past mistakes (I still have to deal with ugly solutions I implemented years ago), you should keep the following recommendations in mind when designing your next web site:
- All the formatting should be done with CSS. Do not use HTML tags to achieve formatting effects. Do not use HTML tables for layout purposes. Do not use format-related HTML attributes.
- Avoid HTML-embedded CSS formatting at all costs. It’s always better to define an extra class that will probably come handy at a later time (exceptions rarely happen only once).
- When multiple classes share the same formatting, define the common formatting only once, listing multiple classes in the selector part of the rule.
- You can use more than one class per HTML element. Use this functionality to reduce the number of classes you need or their complexity.
- Use hierarchical selectors to reduce the number of CSS classes (this will also reduce the size of your HTML markup).
- Store the CSS rules in external style sheets. Structure the style sheets hierarchically and import common style sheets into more specific ones.
< Back
Page 6 of 6