Best practices and advices
15 MayAs i said in previous post, i have some tips and advices for
Use CSS reset
I personally don’t use any of existing CSS reset file and i use only few line for this, including the blamed * {margin:0; padding:0} technique:
* {margin:0;padding:0} img, fieldset {border:none} table {border-collapse:collapse} td, th {text-align:left;vertical-align:top} button {cursor:pointer} input, button, select {vertical-align:middle} textarea {overflow:auto} html { font-size:100.01%; } body { font-size:1em; } a {text-decoration:none} a:hover {text-decoration:underline} input.text, input.password, textarea {border: 1px solid #7f9db9} .clearfix:after {content:".";display:block;height:0;clear:both;visibility:hidden} .clearfix {display:inline-block} /* Hide from IE Mac \*/ .clearfix {display:block} /* End hide from IE Mac */ * html .clearfix {height:1px}
Not only i reset all styles, but i also use a smart way for clearing floats. Just add class=”clearfix” to some floatet box container and here you go. No more clear both extra tag, no more other tricks.
Don’t get me wrong. Every time i’m in a middle of a project i remember to NOT use * {} CSS reset for next project. And every time i forgot
(Don’t) Use CSS frameworks
I don’t like to use code that is not mine. And CSS frameworks is this kind of code. Beside that, when you start to use a framework (no matter what framework is), you MUST learn it. Too much waste of time to learn another people code. Again, you have plenty of CSS frameworks to pick and try.
Validate your code and search for browser bug
Some times a page is not displayed well. Either you have a bug in your code or bug in your favorite browser, you need to figure in a way or other what is guilty for headaches. The best way to eliminate code bugs is to validate your code. If all lines is ok, you should search for bugs in browsers.
Comment your code
You probably say: why should i bother to comment my own code? I wrote it, i will remember! Yeah, sure! Over the past years i convinced myself how much i can be WRONG! I try to read some past code (yes, written by myself) and i ask: what the heck i wanted to do here? So now i comment my code: CSS i split in blocks and on html i comment the closed div/class for big containers:
<div id="wrap"> <div class="header"> content goes here </div><!--/.header--> </div><!--/wrap-->
Read news, blogs and forums
I have a many RSS feeds in Google Reader and half of them is about development. CSS, Javascript or only news, is all good. Of course, i don’t spend too much time reading all articles. I read only headers and if is worthing, i read it all. Is the BEST way to stay informed about web technologies.
Test in many browsers
Don’t matter if you made a website for yourself or for a client, because that site MUST be rendered in the same way in ALL browsers. Or at least to degrade graceful and remain usable.
Use your own javascript vs. libraries
Well, if you read constantly this blog, you know that i’m in love with jQuery
And for most projects i need speed in development and just to be sure i achieve same results in all browsers. I can use my own JS or i can use my own JS powered by jQuery. The second way is always preferred
More to come?
Sure! If i remember any other tips, i will surely tell you! Just add this blog to your reader and stay tuned!

I agree with you.I really like your technique for clearing floats
You might want to try out Eric Meyer’s css reset. It’s clean and only touches generit aspects.
http://meyerweb.com/eric/tools/css/reset/
I use it on all projects, with few minor personal addons.
Also we need to have a talk about you not using those nasty * hacks, even in IE6 and letting go of IE on Mac.
I also use Eric Meyer’s css reset. But i import it with
@import url(cssreset.css);
It’s a simple way to clear all browser default styles and to keep the main css file clean.
“(Don’t) Use CSS frameworks” is one of the greatest advices!
I also wouldn’t like to use frameworks, css, js, or any other technology. However, some of them are really good, and give you a big boost in terms of productivity.
Hi there, I just subscribed to your RSS feed. I like your advice on not using a CSS Framework. I spent ages looking at Blueprint and Yahoo!’s framework for CSS grids.
I found it confusing and somewhat bloated - although I like Yahoo’s! I don’t like their naming conventions though.
How do you deal with form elements when you set * {margin:0; padding:0;} ? I have always found its a pain to reset all elements on a page. As some elements like headings and paragrahps should have some spacing.
Do you have a base class or standard setting you give these elements in all projects?
Hi Gavin and thanks for your subscription
Most problem with form elements i fixed with vertical-align:middle.
Anyway, i started a project few days ago and i start to use Eric Meyer’s CSS reset (because i started to see the “unseen” problems with * reset):
Anyway, most CSS frameworks (actually all existing frameworks, for ANY language - php, ruby, java, and so on) is full of what developers of that framework need. So i prefer to make my own skeleton for CSS and xHTML and work on that (i don’t know how much time you save for having a ready to use 2 columns when you know is THAT EASY to make your own in less than three steps)