<!--[if lt IE 9]> This is less then IE9 ELSE this is all browsers: firefox, chrome, etc. <![endif]-->
How do I do this in my HTML? I want to do an "else" ...
Conditional Statements Use 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.
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 %}.
The <! --[if IE]> syntax only works in Internet Explorer. You'll need to use javascript or css to conditionally display html in other browsers.
The if/else statement executes a block of code if a specified condition is true. If the condition is false, another block of code can be executed. The if/else statement is a part of JavaScript's "Conditional" Statements, which are used to perform different actions based on different conditions.
You're not looking for an else, you're looking for <![if !IE]> <something or other> <!--[endif]>
(note that this is not a comment).
<!--[if IE]> You're using IE! <![endif]--> <![if !IE]> You're using something else! <![endif]>
You can find documentation on the conditional comments here.
I use the following to load resources in IE9 or newer and all other browsers
<!--[if gte IE 9]><!--> //your style or script <!--<![endif]-->
This is hard to believe. Look the opening and closing if statement sections are inside comments (so, its not visible to other browsers) but visible to IE.
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