Detect Internet Explorer Using 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.

This method does not require JavaScript, but it is not as versatile as JavaScript techniques which can also identify different browsers. This technique can only identify IE - all other browsers are lumped together as "not IE".

The code snippets used in this technique are called called conditional comments. The following example simply says "If the browser is Internet Explorer, show this content".

<!--[if IE]>
Place content here to target all Internet Explorer users.
<![endif]-->

The next example is the opposite: "Only show this content if the browser is NOT Internet Explorer".

<![if !IE]>
Place content here to target all users not using Internet Explorer.
<![endif]>

The next example shows the content if the browser version is greater than or equal to 8.

<!--[if gte IE 8]>
Place content here to target users of Internet Explorer 8 or higher.
<![endif]-->

A similar example shows the content if the browser version is less than 7 (i.e. 6 or lower).

<!--[if lt IE 7]>
Place content here to target users of Internet Explorer 6 or lower (less than 7).
<![endif]-->
 

How Conditional Comments Work

Conditional comments are only recognized by Internet Explorer — other browsers treat them as normal comments and ignore them. Note that in the second example above (the one that targets "other" browsers), the content is not actually inside a comment — that's why other browsers display it.

Subscribe to us on YouTube