add conditional comments to make cross_browser (compatible css browser)
  • hi I hope that all well, please how I can add conditional comments based on firefox and google chrome I know that conditional comments based on internet explorer look like that :

    <p class="accent">
    <!--[if IE]>
    According to the conditional comment this is IE<br />
    <![endif]-->
    <!--[if IE 6]>
    According to the conditional comment this is IE 6<br />
    <![endif]-->
    <!--[if IE 7]>
    According to the conditional comment this is IE 7<br />
    <![endif]-->
    <!--[if IE 8]>
    According to the conditional comment this is IE 8<br />
    <![endif]-->
    <!--[if IE 9]>
    According to the conditional comment this is IE 9<br />
    <![endif]-->
    <!--[if gte IE 8]>
    According to the conditional comment this is IE 8 or higher<br />
    <![endif]-->
    <!--[if lt IE 9]>
    According to the conditional comment this is IE lower than 9<br />
    <![endif]-->
    <!--[if lte IE 7]>
    According to the conditional comment this is IE lower or equal to 7<br />
    <![endif]-->
    <!--[if gt IE 6]>
    According to the conditional comment this is IE greater than 6<br />
    <![endif]-->
    <!--[if !IE]> -->
    According to the conditional comment this is not IE 5-9<br />
    <!-- <![endif]-->
    </p>
    Please how can I include comments based on firefox and safari and google chrome thank you .
  • 2 Comments sorted by
  • Vote Up0Vote Down yakhtarali0yakhtarali0
    7.50 Karma Accepted Answer

    Conditional comments are a Microsoft IE-specific rule, and they are not part of any standard. If you check the structure of a conditional comment:

    <!--[if gt IE 7]>

    Here is some code.

    <![endif]-->

    As its name would imply, it is all just a big comment <!-- comment -->. IE checks comments for conditions such as these which, again, do not comply with HTML standards.


    To create code which doesn't render in IE, but does render in other browsers, you use the following conditional:

    <!--[if !IE]> -->

    This will be rendered by anything but IE.

    <!-- <![endif]-->

    See how the conditions are enclosed in closed comments? That's why that is rendered in normal browsers, while IE checks for the conditional, and decides to omit everything up until the endif.

    If you want to add another condition, and keep rendering the code on non-IE browsers, you could use the following workaround:

    <!--[if gt IE 7]> <!-- -->

    Here is some code for anything but IE 7 and below.

    <!-- <![endif]-->

    Note I had to use open the comment again to prevent IE from rendering --> before the code. Other browsers will still consider it part of the comment.

  • Hi yakhtarali0 thank  you very much :) .

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

    Optimum Creative