Cross-Browser CSS Tips - IE 7 Part III

As I continue to code CSS & HTML for multiple browsers, I find that if you follow two 'simple' rules, your design will most of the time come out pretty much the same in all browsers.

1.) Never use padding along with width
This is probably the cause of the biggest headaches as IE 6 renders padding incorrectly. To make everything look the same in browsers, you will probably have to do some extra math and use an underscore or star html hack to set the width differently for IE. So it is advisable to never use paddings with width. If you absolutely have to use padding, create another container (div, span, p etc) and set its margins.

2.) Always remember to clear your floats
This is an IE problem that shows up most commonly in Firefox or Opera. Confused? Now let me explain. In IE 6 even when you don't clear your floats, the parent container will still rap around the inner content. However rendered correctly, the parent container would only appear for maybe five pixel at the top of the page and your child container seems to break out of its parent container and extend to the bottom of the page. So in Firefox when you see your parent container appearing only at the top of the page for a few pixel, remember to check if you cleared your floats or not.

Please keep in mind that these are tips for rendering designs the same in different browsers and not tips for how to code CSS. For example with tip number one, if you put a div that is 800 pixels wide with 10 pixels margin all around in a div that is only 800 pixels you will still get an expanded parent div, but at least it shows up the same in all browsers; whereas if you put a div that is 800 pixels wide in a div that is 800 pixels with 10 pixels padding, who knows what's gonna show up.


  1. 渝都散人 said,

    Hi,one of your templates:Andreas02:
    works correctly in Firefox,but malfunction in IE7.Can you fix this problem?Those navtaps hide behind the picture,and the sidebar drops to the bottom.

    on 6:51 AM

  2. rosy said,

    What a great idea! I can't wait to read some new blogs! I just submitted my faves. :)
    web development professional development

    on 4:27 AM

  3. Reynold Hugh said,

    What a Helpful Addition!
    CSS Page Templates

    on 4:29 AM