less of how & more of a why question here...I tried searching around some & couldn't quite find the answer I was looking for.
I'm curious why conditional comments exist within IE? did Microsoft implement this into the different browser versions because they knew they were not standards compliant?
I know certain version of other browsers can be targeted using conditional comments but those for IE far outnumber any other browsers.
I'd be interested in hearing any info regarding the origin & history of conditional comments.
Conditional comments are conditional statements interpreted by Microsoft Internet Explorer versions 5 through 9 in HTML source code. They can be used to provide and hide code to and from these versions of Internet Explorer.
Conditional comments are conditional statements to hide or provide HTML source code from Internet Explorer. 2. There are two types of conditional comments - downlevel-hidden - which is used to hide HTML source and downlevel-revealed which is used to reveal HTML source code in Internet Explorer.
IE means “not IE”. gt means “greater than”, gte means “greater than or equal”, lt means “less than”, lte means “less than or equal.” Note that IE 10 and up DO NOT support conditional comments at all.
This method allows you to use simple code in your HTML to detect Internet Explorer (IE). You can determine whether or not the end user is using IE, and if so, which version. This allows you to provide content based on which browser is being used.
They implemented it with ie5 and saw it as a good thing to optimise sites for IE.
Conditional comments have certain advantages over scripting methods of browser detection.
When a downlevel browser encounters a downlevel-hidden conditional comment, the browser skips over the HTML inside the comment, and the content elements are not parsed, downloaded, or rendered. This saves client machine resources.
Conditional comments do not require scripting and DHTML, and when no scripting is used in a Web page, no scripting engine needs to be loaded. Conditional comments are processed during the downloading and parsing phase, so only the content that is targeted for the browser is actually downloaded. Conditional comments can be combined freely with other browser detection techniques.
Using conditional comments, script logic can be separated into smaller and simpler segments of code, which are easier to maintain and understand. Plus, code segments are loaded only by the browser version for which they were intended.
Conditional comments have been around since Internet Explorer 5, but their use is not restricted to Internet Explorer alone. Conditional comments can be used to customize content delivered to browsers that support conditional comments and those that do not.
more info: http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With