HTML Comment

Whenever you need to keep a note inside your program for your future reference and at the same time you want that the program should not execute it, you have to use comment tag <!-- -->. Whatever you put between <!-- and --> tags in the body of your web page will not be executed and will be just ignored by the browser.

Many programmers use the comment tags to disable particular sections of coding during test running of their coding.This is more useful when you have a complex and lengthy code.

Syntax

<!-- This is a comment line -->

Example

<!DOCTYPE html>
<html>
<head>
<title>Comment Example</title>
</head>
<body>
<!-- This is a comment line -->
Welcome to TechStrikers!
</body>
</html>

This will produce following result

Welcome to TechStrikers!

Conditional Comments

In HTML, comments can be used to define conditions, lets assume that you need to execute or render some piece of HTML code in Internet Explorer. You can do this by using HTML conditional comments.

Syntax

<!--[if IE 8]>
    .... your HTML code come here ....
<![endif]-->

Example

<!DOCTYPE html>
<html>
<head>
<title>Comment Example</title>
</head>
<body>
<!--[if IE 9]>
<link href="ie9.css" rel="stylesheet" type="text/css">
<![endif]-->
<!--[if IE 8]>
<link href="ie8.css" rel="stylesheet" type="text/css">
<![endif]-->
<!--[if IE 7]>
<link href="ie7.css" rel="stylesheet" type="text/css">
<![endif]-->
</body>
</html>

See Also

HTML Form Tags
HTML Page Formating Tags
HTML Other Tags


 
 
SHARE THIS IF YOU LIKE!
submit to reddit

SUBSCRIBE FOR LATEST UPDATES
HAVE WE CONNECTED ON FACEBOOK?
TOP TUTORIALSTOP CODE EXAMPLESTOP LIVE DEMOLINKSSTAY CONNECTED
HTML Tutorial
HTML5 Tutorial
Bootstrap3 Tutorial
Javascript Tutorial
TypeScript Tutorial
AngularJS Tutorial
CSharp Tutorial
PHP Tutorial
Developer Tools
Javascript
AngularJS
Google MAP API V3
ASP.NET
Javascript
AngularJS
Google MAP API V3
Contact Us
Advertise with Us
Privacy Policy
Disclaimer
Stay connected. We actually like you. If you want to get up to the minute updates, then connect with us on your fav below.
 
Twitter   Linkedin   Facebook   Google+    RSS   Pinterest
 
Protected by Copyscape Original Content Checker
 
 
Copyright ©2017 www.techstrikers.com Unauthorized reproduction/replication of any part of this site is prohibited.