Can anyone recommend the best way to hack IE8 styling via CSS, I’ve recently been making IE8 render as IE7 for ease – but wondered if it was best to add IE8 hacks?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should reverse your method. First your site should look good in modern browsers (like Firefox, Chrome, Opera, IE 9), and then you can start worrying about the others.
As others suggested, conditional comments can be your friend.
First, you should develop your CSS to look fine in the modern browsers. Then check IE8, see what problems you get. If you need to, include an IE-specific stylesheet. After that, you can check in IE7 and then IE6 if you support it, and add further fixes.
An example:
In this case you include
normal.csswhich is for modern browsers. You found some strange IE8 issues, so inie8.cssyou fix the problems. You don’t have to include all your selectors in this, only the ones that need a fix (the values will be overridden for IE 8 and lower). After that, if there are still some strange things in IE7, you can add yourie7.cssand fix those, and so on.Please refer to the links the others gave you to get more information on the usage of conditional comments.
Finally:
making IE8 render as IE7 for easeis never a good idea, and should be avoided. IE7 is the far past (in the IT world, IE8 should be the far past either…), develop for the present and the future, and after that you can care about the people who are still stuck with old technology (based on your audience and business plan).