The Universal Zero Rule

It’s old, it’s been used a million times before, but I guarantee it’ll fix 99.9% of the margin and padding errors you’ll come across. The Universal Zero Rule is a very simple snippet of CSS that you can add to the beginning of your CSS document.

Many times when coding a page using CSS you’ll find that even though you’ve specified certain padding and margin values they may be off by a few pixels, mainly because each browser has it’s own default value, which it will add to the element. The UZR resets these values to zero so that you can define your own measurements without having to worry about browser interference.

Simply add it to the beginning of your CSS document and it should fix most of the problems you’ll come across without the need for hacks or other workarounds. Copy and paste and you’ll be all set. If you want you can even define and overwrite default browser colors, backgrounds, etc by adding other properties to the selector.


*{
  margin: 0;
  padding: 0;}
Advertisements

1 Comment

Filed under Design, Miscellany, Web Design

One response to “The Universal Zero Rule

  1. Also there’s the YUI reset.css file that resets everything for you. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s