Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why are conditional comments implemented in IE? [closed]

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.

like image 571
axelav Avatar asked May 17 '11 02:05

axelav


People also ask

Which is the only browser that supports 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.

What is conditional Comment in HTML?

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.

What is IE condition?

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.

What is IE HTML?

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.


1 Answers

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.

  • Low client-side impact.

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.

  • No script required.

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.

  • Separate code from detection logic.

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.

  • Cross-browser.

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

like image 51
cmplieger Avatar answered Sep 25 '22 16:09

cmplieger