Articles → HTML → Conditional Comments In HTML

Conditional Comments In HTML






Purpose Of Conditional Comments





Syntax


<!--[if (expression)]>HTML<![endif]-->



Predefined Strings




  1. IE – Check whether the browser is internet explorer or not.
  2. WindowsEdition - Check the operating system installed on client’s machine.

Example




<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta charset="utf-8" />
      <title></title>
   </head>
   <body>
      <!--[if (IE)]>       Internet Explorer <![endif]-->
      <!--[if !(IE)]><!--> Other than IE<!--<![endif]-->
   </body>
</html>



Output




Picture showing the output of the conditional comments in html in chrome and IE browser

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Sunday, January 15, 2017

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250