You might have heard mention of this going around the Internet for a few months now – as this was technically announced back in July on the IE Blog – however I just wanted to clear a few things up here. For starters make sure you understand what conditional comments are – and how that really affects you.
One of the most common functions performed in a Web page is to detect the browser type and version. Browser detection is performed generally to ensure that the content presented to the browser is compatible and renders correctly across all browsers. The browser type can be detected using many different techniques – however Internet Explorer has always been the one lagging behind the most – and as such often times you really only need to detect for IE. Conditional comments make it easy for developers to write pages that downgrade gracefully in less-capable browsers or to make sure the pages display correctly in Internet Explorer.
Conditional comments are the preferred means of differentiating Cascading Style Sheets (CSS) rules intended for specific versions of Internet Explorer. For example, let’s say we know that in Internet Explorer 8 we have a few CSS issues with a website. We create the IE8 specific CSS fixes, and would use the following code to tell Internet Explorer 8 that it should load an additional CSS file.
<!--[if IE 8]> <link rel="stylesheet" href="/style/ie8.css" media="screen" type="text/css" /> <![endif]-->
These commands however will be completely ignored by IE10 – and that might not really be such a bad thing. One of Microsoft’s main goals with IE10 was to make sure that it parses a page the same exact way every other browser does – thus eliminating the need for conditional comments. Conditional comments will continue to work for all older IE releases – so you can still target the older browsers and issue specific commands. Provided IE10 is able to parse a page as good as Google Chrome or Mozilla Firefox – I really won’t mind the lack of conditional comments – however I would hate to have to resort back to browser sniffing.
Leave a comment