Sunday, January 2, 2011

IE CSS Hacks

Internet Explorer.

It doesn't matter if it's IE 6, IE 7 or IE 8, they all suck.
Even though IE 8 has made some progress concerning CSS issue, IE 7 and obviously IE 6 are the worst browsers.

With CSS compatibility issues from here to Bill's office it takes too much work to make one CSS file fit all. That's why I thought of a small hack that I make in every HTML / XSLT / ASPX document I'm working with.

at the body tag of each page I insert a small html if:

<!--[if IE 6]>
<body class="ie6">
<![endif]-->

<!--[if IE 7]>
<body class="ie7">
<![endif]-->

<!--[if IE 8]>
<body class="ie8">
<![endif]-->

After placing that, you can easily create inside your general CSS file an inherited styling such as:
body
    { margin: 0 0 0 0; }
body.ie6
    { margin: 0 5px 0 0; }
body.ie7
    { margin: 0 0 5px 0; }
body.ie8
    { margin: 0 0 0 5px; }


This is the easiest way for me to work with IE 6 and IE 7 (and sometimes IE 8).  There is another way to make style compatible with IE browsers which involves creating different CSS file for every IE:


<link rel="stylesheet" type="text/css" href="general.css" />

<!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="generalIE6.css" />
<![endif]-->

<!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="generalIE7.css" />
<![endif]-->

<!--[if IE 8]>
    <link rel="stylesheet" type="text/css" href="generalIE8.css" />
<![endif]-->


Good luck, and hopefully we won’t need any CSS hacks for Internet Explorer 9,
Elad Shalom,
CTO at ITweetLive.com

6 comments:

  1. Download All Recent Games , Movies And Apps For
    Free at http://estrip.co.kr/entry/201210251312?
    category=0

    You can download from the following categories

    Applications (RSS)
    Android (RSS)
    iOS (RSS)
    MAC (RSS)
    Windows (RSS)
    Ebooks (RSS)
    eBook (RSS)
    Magazines (RSS)
    Games (RSS)
    Linux (RSS)
    MAC (RSS)
    PC (RSS)
    PS3 (RSS)
    PSP (RSS)
    Wii (RSS)
    XBOX360 (RSS)
    Movies (RSS)
    BDRiP (RSS)
    Cam (RSS)
    DVDRiP (RSS)
    DVDRiP Old (RSS)
    DVDSCR (RSS)
    HDRiP (RSS)
    R5 (RSS)
    RC (RSS)
    SCR (RSS)
    Staff Picks (RSS)
    Telecine (RSS)
    Telesync (RSS)
    Workprint (RSS)
    Music (RSS)
    Albums (RSS)
    iTunes (RSS)
    MViD (RSS)
    Singles/EPs (RSS)
    Staff Picks (RSS

    Download everything for free at http://estrip.
    co.kr/entry/201210251312?category=0

    ReplyDelete
  2. Fabulous, what a website it is! This weblog provides valuable facts to us, keep
    it up.

    Look into my weblog :: minecraft download

    ReplyDelete
  3. Hi! I could have sworn I've been to this website before but after browsing through a few of the posts I realized it's new to me.

    Anyways, I'm definitely delighted I discovered it and I'll be bookmarking it and checking back
    frequently!

    Here is my weblog - dragonvale hints and cheats **

    ReplyDelete
  4. Having read this I thought it was rather informative.

    I appreciate you taking the time and effort to put this short article together.
    I once again find myself spending a lot of time both reading and posting comments.

    But so what, it was still worth it!

    My web blog :: play minecraft for free

    ReplyDelete
  5. Its not my first time to go to see this web page, i am browsing this
    web site dailly and get good facts from here everyday.



    Look at my website castleville secrets

    ReplyDelete
  6. I'm excited to uncover this great site. I want to to thank you for ones time for this particularly fantastic read!!
    I definitely savored every little bit of it and
    i also have you book marked to look at new things in your web site.


    Also visit my webpage comptoir quartz ou granit Quebec

    ReplyDelete