Browser detection html code

Need some method for browser detection with HTML itself, here it is.

With this method you can detect whether your browser is IE or non-ie (i.e. mozilla firefox, safari, opera etc.)

Now you won’t have to write server side script such as php, .net and others or client side script such as javascript or vb script for browser detection and accordingly output your HTML code.

The method is simple as shown below:

For displaying HTML code only in IE:

<!--[if IE]> Here comes the HTML Code <![endif]-->

For displaying HTML code in browsers other than IE:

<!--[if !IE]>--> Here comes the HTML Code <!--<![endif]-->

Also you can have your code work with different versions of IE.
<!--[if lt IE 7]> Here comes the HTML Code <![endif]-->

here the HTML code will work only for IE having version less than IE 7. and here lt means less than

also you can even write lte which means less than equal to

Hope this method help you out with your problems.

Sachin (

7 thoughts on “Browser detection html code

  1. What if I need to separate non-ie code among the other major browsers like mozilla firefox, safari, opera and chrome?

  2. I’m studying how html works…among other things…
    Thank you for your time.
    It helps. I help others when ever I can…

    Thank you,
    J the student

  3. Hi, your information is good.
    I want to exactly know the browser name. If I am using Mozilla, it should say Mozilla. If Safari, then Safari.
    And I have to do this only using HTML. In your method, the non-IE browsers are grouped together.
    I don’t wanna use JS as the code will be written for a JS disabled browser.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s