LSW Posted December 22, 2008 Report Posted December 22, 2008 This is not a right or wrong thread, just two way of doing things and the reason for that. So hacks are bad - most of us agree. A hack is a code style that takes advantage of bugs and mistakes in browsers. If the browser is fixed, the hack does not work and the site is likely broken. Discussing this in another forum a comment was made that rings true and should be mentioned here. So a few points to consider: Hack Con - Requires a mistake or bug in a browser to work, it that is fixed the hack fails. Con - Makes the CSS not valid Pro - A hack is placed alone in the CSS, when the CSS is external this means you need but remove it from the style sheet to be rid of it. Condition Comments Con - They have to be placed in your markup, every single page... Con - They muck up pure structured code & invalidate your code Con - You are playing to the whims of the most popular browser yes, but you are writing incorrect code due to one single user agent out of the dozens that you may have visit your site, logical to cater to one single broken user agent? Pro - You are creating styles for IE in a form that only IE will read leaving your CSS pure for standards based browsers. Conclusion The choice is yours, would you rather have pure structure or pure CSS? Would you rather write a hack in a single document or would you rather write a comment/s in every page of your site? Course with the smart use of Templates or includes you can limit this. So this is not a do or do not, simply consider this and what comments will follow and make an informed decision whether to use Hacks or Comments. IE7 has improved but there are still some problems with IE7 and Opera 9 and a whole new series of Hacks will be needed. IE7 has blocked the * html hack which was often used to correct Layout problems in IE, however those layout problems have not been corrected, they still exist bit the hack does not. Quote
p4c Posted January 8, 2010 Report Posted January 8, 2010 I have a need to do a few things first i wanted to be able to send php code to multiple browsers but not the same code. I ran into a problem with this and on top of that, i wanted to send multiple stlyesheets to different browsers. CC's worked for the second task but I had to make a few "new" hacks to get them to serve my purposes with PHP. These "hacks" that i have created are designed to target 3 browsers, and differientiate between the 3. 2 of which are not IE, meaning firefox, and Google Chrome; using these following "hacks" in conjunction with a "" allows one to distinguish and pass different (x)HTML, CSS and PHP data to the browsers. I have these set up in a seperate php file than the actual "index" file of the webpage and they are included by employing a SSI. Below is a copy of that file. Detect IE, firefox and chrome hacks by : p4c - nick gibson i hope these will be some help and service to others. they are for me. -------------------------------------------------------------here is the file---------------------------------------------------------------------- ________________________________________end of file__________________________________________________ it is my hope that these will perhaps suppliment the * html hack that no longer works, due to IE7. another thing is that chrome doesnt like background-image styles from imported sheets, but if you append the holy * html hack like so the issue goes away. /* Hides from IE5-mac \*/ * html body{height: 1%;} /* ENABLES CHROME TO BE CSS2 COMPLIANT */ /* End hide from IE5-mac */ good day, and god bless -- keep coding keyboard samuris Quote
asdfghjkl Posted April 19, 2010 Report Posted April 19, 2010 I'm new familiar with 'Conditional Comments or Hacks'. May be it helpful for me in future. Thanks. Quote
Guest Paul Stephen Posted May 5, 2011 Report Posted May 5, 2011 I am a fresher in design and also 1st time hear about "Conditional Comments or Hacks" here.nicely posted... Quote
Ken Peterson Posted June 23, 2011 Report Posted June 23, 2011 This is not a right or wrong thread, just two way of doing things and the reason for that. So hacks are bad - most of us agree. A hack is a code style that takes advantage of bugs and mistakes in browsers. If the browser is fixed, the hack does not work and the site is likely broken. Discussing this in another forum a comment was made that rings true and should be mentioned here. So a few points to consider: Hack Con - Requires a mistake or bug in a browser to work, it that is fixed the hack fails. Con - Makes the CSS not valid Pro - A hack is placed alone in the CSS, when the CSS is external this means you need but remove it from the style sheet to be rid of it. Condition Comments Con - They have to be placed in your markup, every single page... Con - They muck up pure structured code & invalidate your code Con - You are playing to the whims of the most popular browser yes, but you are writing incorrect code due to one single user agent out of the dozens that you may have visit your site, logical to cater to one single broken user agent? Pro - You are creating styles for IE in a form that only IE will read leaving your CSS pure for standards based browsers. Conclusion The choice is yours, would you rather have pure structure or pure CSS? Would you rather write a hack in a single document or would you rather write a comment/s in every page of your site? Course with the smart use of Templates or includes you can limit this. So this is not a do or do not, simply consider this and what comments will follow and make an informed decision whether to use Hacks or Comments. IE7 has improved but there are still some problems with IE7 and Opera 9 and a whole new series of Hacks will be needed. IE7 has blocked the * html hack which was often used to correct Layout problems in IE, however those layout problems have not been corrected, they still exist bit the hack does not. Thank you. Its helpful to me. Quote
Andrea Posted June 23, 2011 Report Posted June 23, 2011 Thank you. Its helpful to me. Keep in mind htat this was written in 2008 - so a couple IE versions ago. Things are different for IE7 and newer than they were for 6 and under. Quote
bsmbahamas Posted January 6, 2012 Report Posted January 6, 2012 i really liked this post. personally i don't use hacks or conditionals but then again i don't have to support IE, and when i do, i stick to a subset of css that i already know works well in all the major browsers including IE. if i really had to though as you suggest, i'd use an include file, and if need be just wrap it in an if( file_exists('file-name.php) ){ include 'file-name.php'; }, so i could simply delete the include file later and the site would just ignore the call to include(). 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.