Using CSS For Better Coding
Reference | in html & css
Messy CSS is one of the most common complains developers have. And more often that not it is the result of a bad coding job that has been done. However, writing clean and manageable CSS is not a difficult job when you know how to go about things.
Here ares some tips that will helps you write slimmer and faster CSS and also ease the process of the same.
Be Organized
Organization is important in all the processes of the design and development procedure. Use a coherent structure instead of randomly specifying id's and classes. This subsequently helps the stylesheets to benefit from the style inheritance. Always specify your most generic forms before the non-generic ones so that your CSS can inherit attributes properly. This will make it much more easier to edit the CSS later on and make any changes there.
Specify the Credentials
Don't forget to assign the time, date and sign credentials for your CSS. Its important to let people know who wrote your CSS, the date when it was written and who can be contacted in case of any queries. This becomes especially useful when you design templates or themes.
Save Templates
When you finalize the structure of the CSS, remove all the non-generic elements and save the file as a CSS template that can be used afterwards also. In fact, you can save a number of templates as and when you create something different. For example, two-column layout, mobile, print etc. When you have saved templates you would not have to re-write each and every stylesheet. Instead, you can just make some changes on the template and customize them for use.
Use Naming Conventions
Instead of specifications like col-left and col-right, use some generic naming conventions using alpha, beta etc. This avoids any confusion in the HTML and makes it easier for you to alter the positions of the same. CSS allows for the separations of style from the content which further enables you to redesign an entire website just by modifying the CSS. This is why it is important to use versatile and consistent naming conventions.
Use Hyphens in place of Underscores
Older browsers don't render well when CSS contains underscores and don't support them either. Therefore, it is always better to use hyphens in order to gain some compatibility.
Avoid Repetition
Instead of specifying the styles again and again, learn to re-use the CSS attributes by grouping elements together. For example, if all your h1 and h2 elements have the same font size, colors and margins, it would be better ti group them using a comma instead of repeating it over and again.
Optimize further
When you have lightweight stylesheets, your website would load faster and also it would be easier to maintain and make updates. The most important thing while shrinking the size of stylesheets is trimming off whatever you don't need and them merging similar items under groups. Also, you can skip specifying a unit if measure when using 0. This is because zero is always zero by default irrespective of the unit of measure.
Kabir Bedi is a senior web consultant at LeXolution IT Services, a reputed offshore web design company based in India. The company specializes in providing a variety of web services like web design & development, website maintenance services and internet promotion.
![]() |
OLDER: How Do You Know When Its Time To Get Your Website Redesigned? | | | NEWER: Press Release Distribution-The Most Effective, Immediate and Authentic Way to Communicate with your Audience | ![]() |
Read Back Issues of WHIR Magazine
October 2009 - Web Hosting's All Star Team
This has been, for us, one of the most interesting, exciting and challenging build-ups to an issue of the magazine yet, Web Hosting's All Star Team. The balloting process was our first experiment with a kind of user participation we're planning to do a lot more with in the months to come. We had thousands of ballots submitted, with hundreds of write-in suggestions and a demonstration of user engagement that has us feeling super positive about the project.
About This Issue | Read Digital Edition
July 2009 - What am I Worth?
One of the interesting luxuries of working on a project like the printed WHIR magazine is that it allows us to play with things like our point of view from one issue to the next. In recent months we've been giving added attention to the kind of practical and applicable advice aimed at smaller hosts and resellers. This issue carries on with that point of view, asking, in our cover story, "what am I worth?" It's a complicated question without a clear-cut answer.
About This Issue | Read Digital Edition
May 2009 - The Blueprint for a Small Web Host
I was a little surprised by how difficult it became to see this idea through. We set out to assemble a blueprint for a small hosting business, but butted up pretty quickly against the general impossibility of covering all the territory that was out there to be covered. The basic constraints of a printed magazine, and the less-than-infinite amount of time we had available forced us to face the fact that we could never produce an exhaustive guide to starting a hosting company.
About This Issue | Read Digital Edition






















Comment anonymously or log into your WHIR account
Logging in allows enhanced commenting features (such as external linking) in news, features, blogs and more.