HTML IF Statement

后端 未结 7 1570
走了就别回头了
走了就别回头了 2021-01-12 06:55

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

[I         


        
相关标签:
7条回答
  • 2021-01-12 07:22
    [If lte IE 6]
    

    This selects IE 5, 5.5 and 6. It's the closest to what you want.

    0 讨论(0)
  • 2021-01-12 07:26

    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.

    0 讨论(0)
  • 2021-01-12 07:26

    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.)

    0 讨论(0)
  • 2021-01-12 07:26

    The closest thing I can think of is *NgIf or using ternary expressions in your html using angular - however, the assignment of the variables and the logic of that ngif statement would be done in javascript.

    0 讨论(0)
  • 2021-01-12 07:30

    Not in HTML. Consider using JavaScript instead.

    0 讨论(0)
  • 2021-01-12 07:33

    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.

    0 讨论(0)
提交回复
热议问题