CSS Best Practices: Content Separation, Commenting and DOCTYPES

More and more web designers are using CSS in web design. It is important that when designing a website using CSS the web designer stick to best practices to ensure that you get a clean results and a manageable website. Some of the best practices for CSS include:

  • Separate content from presentation - By separating the content from the presentation part you will free yourself (the web designer) from having to deal with the content portion. It also results in great in ease in terms of updating and the site’s contents since it can be done per page/section without affecting the other parts of the website.
  • Commenting on your stylesheet - We all know how hard it can be to decipher someone’s code. Make it easy for whoever it is you are working with and for yourself as well to review your code and to find any information or command you might need by placing appropriate comments in your stylesheet. You can place comments to help you remember details about your last update, to aid in the organisation of the code, to clarify a bit of code or an approach you took so that another developer will easily understand what you have done, etc.
  • Use DOCTYPE - Common DOCTYPES include HTML 4.01 Strict, HTML 4.01 Transitional, XHTML 1.0 Strict and XHTML 1.0 Transitional. Though this is not a must, using a DOCTYPE is essential if you wish to validate your HTML. Since we know that validating your code is a best practice (not just for CSS) then you should use a DOCTYPE.

to be continued…

Go back