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 but [If!IE6]
and things like that, is that even possible?
Thanks a lot
Edit: I want to compare just scalar numbers, cause I have a dynamically created HTML. For example [If 4 == 6]
. I DON'T WANT TO CHECK IE VERSIONS.
Conditional StatementsUse if to specify a block of code to be executed, if a specified condition is true. Use else to specify a block of code to be executed, if the same condition is false. Use else if to specify a new condition to test, if the first condition is false.
Not in HTML. Consider using JavaScript instead.
How to Build HTML for Conditional Links. Like we learned in the above example, conditional statements are best used outside your the Insert Link html elements. You will want to define your primary condition, then build the content to display after. Use {% else %} for your fallback content, and end with {% endif %}.
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.
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