Cascading Style Sheets – or CSS for short – allows web designers to separate the presentation of their sites from the content. CSS can be used to style any element of your page or place the elements on the page.
CSS can be an extremely powerful markup language for designers.
However, the CSS that is produced is only as good as the principles that are being followed by the designer creating the code.
While you may think that anyone can crank out CSS, there is a big difference between writing CSS and producing top notch CSS.
To ensure that you are on the right track, here are eight CSS principles that every web designer should be following.
Are you following these principles for CSS?
- Take the Time to Validate – Many of us take the time to validate our HTML/XHTML code BUT do we do also validate our cascading style sheets? Is the doctype you use up-to-date and correct?
- Document (but not in your code) – Adding comments to your style sheets will help you understand why you did what you did a week or a month from now. It will also help if someone else needs to take over the project at a later date. Adding comments directly to your CSS code will increase the size of the file and, as a result, increase load time. To avoid this, comment your css in a separate file.
- Say No to Hacks
- Don’t Abuse Divs – Use the appropriate HTML tag instead of automatically creating a new div.
- Put Thought Into Your Class Names –
- Embrace Shorthand
- Don’t Forget About Printers – It’s important to use CSS to make your content printer friendly.
- Never Stop Learning – continue to work on learning more about css.
Read Are You Following the Principles of Top Notch CSS Design? in its entirety.