loading..

loading, please wait...
Mohit Aneja a.k.a CSSJockey

CSSJockey.com

Hello! I am Mohit Aneja, Designer and Developer based in India.
I believe in creating a Unique & Practical Web Presence not just html pages.
If you need some cool stuff, let's talk :)

CSS Tips – Get Consistent Results in All Browsers

Web standards are prevailing guidelines used on the World Wide Web to ensure web sites and information is accessible to all in the most efficient manner. Most Web browsers have different default settings for the base margin and padding.

This means that if you don’t set a margin and padding on your body and xHTML tags, you could get inconsistent results on the page depending upon which browser your users are using to view the page. A simple way to solve this is to set all the margin and padding on the xHTML and body tags to 0:

html, body {
margin: 0px;
padding: 0px;
}
html

This will keep your design structure in the same place on all browsers.

Borders

You may be thinking “but no browsers have a border around the body element by default”. This is not strictly true. Internet Explorer has a transparent or invisible border around elements. Unless you set the border to 0, that border will mess up your web-page layouts. So add the following to your body and xhtml styles:

html, body {
margin: 0px;
padding: 0px;
border: 0px;
}
html
Here’s a nice and detailed article on CSS Reset: Resetting Your Styles with CSS Reset Stay tuned for more web-design tips.

You may also like to read..

7 Comments on CSS Tips – Get Consistent Results in All Browsers


  1. Apr 13, 2011 / Gary Corbett:
    Good tip, all designers should learn the need to reset default browser CSS styles, or the need for it after viewing their work across several browsers.P.S. Good site design! Reply
  2. May 03, 2009 / Banago:
    I use and I think is better to use this piece of code:
    * { padding: 0; margin: 0; )
    
    Reply
  3. Apr 28, 2009 / Tim:
    This is a really informative site. Reply
  4. Apr 25, 2009 / CSSJockey:
    And when you're using a Reset Stylesheet, make sure you link it before your own custom Stylesheet when doing the (x)HTML of the website. I have seen several people posting in forums about their stylesheets not working at all. And in the end, the only issue that appears is that they had invoked the reset stylesheets after their own custom stylesheet! Reply
  5. Apr 25, 2009 / Cody:
    I go even further when resetting css. I make a separate css file that pretty much resets all elements of html. The only elements I leave out is the ones I'm not going to use for the project. Then use a different css file to do my designing in. Reply
  6. Apr 24, 2009 / Abhinav Sood:
    Resetting your HTML styles is the most basic and one of the most important thing to do when developing a website. Overlooking this is the root of several ugly websites that litter the web and break across different browsers.In addition to the above, I generally use these with the HTML and BODY tags: font-size: 100%; vertical-align:baseline; background: transparent; Is helpful in cases when users have styled their browser (background color, larger font size, etc.) or some browser skins that may change the appearance of a web page. Reply
    1. Apr 10, 2012 / sina:
      Great Buddy Reply

Leave a Reply

Stay up-to-date

Get latest tutorials and articles directly in your email.

Subscribe in RSS Reader

Connect via Facebook

Follow me on Twitter

Visit our Google+ Profile

Connect via Skype

I keep my Skype open all day long while I work on my computer.
Feel free to ping me to start conversation.

I love good conversations!!
If you have some big ideas, suggestions, feedback,
or want to discuss your project give me a shout.

 
%d bloggers like this: