good css practices.

Hints HOWTOs

I was recently asked to recommend and comment on some good CSS practices for a client and I thought I would pass some of them.

  • Use a table of contents. I always start my stylesheet(s) with a table of contents so I can easily locate particular styles in the future. I would recommend breaking your stylesheet into a few main areas like: header, main content, navigation, footer. The more sections you put in, the easier it is to read and edit at a later date.
  • Use a table of contents. If you notice your stylesheet is getting out of control (over 1,000 lines) consider using multiple style sheets. You could have one master style sheet, another for forms, another for specific pages, etc. You would then either link to a stylesheet that would have links to all the styleheets using @import or you could call in the stylesheets on a page by page basis statically or dynamically.
  • Start with a known, debugged code if possible. I have a library of layouts that I use when beginning a new project that I know work in multiple platforms on multiple browsers. I will be publishing these as soon as I have some free time.
  • Do not rely on CSS hacks, unless it is a last resort. Believe it or not, most things can be done with CSS code that will validate. As soon as you rely on hacks, your code becomes unpredictable with new browser releases. Stick to valid code that you know will work with past and future builds of browsers. There are a lot of hacks out there which seem like a quick and easy fix, but you will pay for it down the road.

I hope this helps! CSS is a little tricky and sometimes very frustrating, but in the end…clean code is very rewarding.
[tags]CSS, CSS tips[/tags]

Leave a Reply

Your email address will not be published.
*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Apple Hints HOWTOs

outlook users having issues with mail.app attachments.

A few days I came across a problem with Microsoft Outlook users not being able to open any attachments sent by someone using Apple’s Mail.app application (the default Apple email application). Fortunately the fix is quick and easy! The real problem: Apple, by default, uses a “Rich Text Format” (RTF) for composing all new email […]

Content Management Systems Web Development WordPress

WordPress Newsletter Plugin

I have been working with WordPress for multiple years now and I decided I needed to start reviewing some of my favorite plugins – as I receive a number of requests about what plugins I use/prefer. I am going to start with a newcomer: WP Newsletter. This plugin works great for WordPress sites allows you […]