- 1
Reset CSS
All browsers have different default margin padding values and we don't want to need to specify margin padding each time when we define a new class. So let's reset default margin and padding.
- 2
Internet Explorer Tips
We all know that the Internet Explorer series causes trouble. Here are some particular techniques for detecting IE version and composing a special CSS to hand differences.
The code above links IE.CSS if the browser is Internet Explorer regardless of its version. And here is a more specific one for version detection.
But I prefer inline separators unless there isn't any major change. For instance:
So if you run the code above and test it using for instance, BrowserLab, you'll realize that ...
...makes the box's background black for IE6 and IE7 whilst it is red for rest of the browser sets.
If you remove that line and rerun the test, IE6 will render the box background as green, IE7 will render the box background as blue, while IE8 and other browsers rendering will be red.
Also if you just want to assign attribute value for IE6 you may use !important
For instance:
As the output of the line above, IE6 will render the background as red because it doesn't know the command of
!important
whilst other newer browsers render it as black and won't override the first value due to that directive.
- 3
Having trouble with other browsers?
Sometimes we may need to define special handling just for Safari:
Or for Chrome:
If we just append the browser set fixes at the very bottom of our CSS sheet, they will basically override previous definitions for specified browsers.