HTML Page Structure

HTML Elements
HTML Attributes


HTML Comments

HTML Comments is usefull 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>