Skip to content Skip to sidebar Skip to footer

HTML IF Statement

I just wanna know how to do an if-statement in simple HTML. Like the [if IE6] thingy I'd like to do something like this [IF 5>6] How's the syntax? I can't seem to find anything

Solution 1:

Not in HTML. Consider using JavaScript instead.


Solution 2:

No, it's not possible. What you have seen is conditional comments in IE, which only checks version numbers of IE, and is typically used to inject IE specific style sheets to fix CSS bugs for that particular browser.


Solution 3:

The <!--[if IE]> syntax only works in Internet Explorer. You'll need to use javascript or css to conditionally display html in other browsers.


Solution 4:

If you want to check for browser versions:

<!--[if lt IE 7]>
    <!-- For LOWER than IE7 -->
<![endif]-->

<!--[if IE 6]>
    <!-- For JUST IE6 -->
<![endif]-->

<!--[if gt IE 7]>
    <!-- For HIGHER than IE7 -->
<![endif]-->

Other than that, you cannot use if statements in HTML, as it is a markup language and not a programming language. You need to do it either server side or with Javascript.


Solution 5:

I believe this is the page you are looking for http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx

(I typed into google "IE conditional comments". It was the second result.)


Post a Comment for "HTML IF Statement"