Comment is a part of code which is used to add comments into HTML code, particularly in complex documents, to indicate part of a document. Comments assist you and increases code readability.

HTML comments tag start and closed with the following <!– … –> tags and this tag is ignored by the browser.

Example:–

<!DOCTYPE html>

<html>

<body>

<p>This is first paragraph.</p>

<p>This is second paragraph.</p>

<!—This is comment tag –>

<!– Do not display this at the moment
<img border=”0″ src=”comment.png” alt=”comment”>
–>

</body>

</html>

Conditional Comment

Example:–

<!DOCTYPE html>

<html>

<body>

<!–[if IE 8]>
…. some HTML Code here ….
<![endif]–>

<p>This is first paragraph.</p>

<p>This is second paragraph.</p>

</body>

</html>

Multiline Comment

Example:–

<!DOCTYPE html>

<html>

<body>

<!–   This is first line of comment.

This is second line of comment.–>

<p>This is first paragraph.</p>

<p>This is second paragraph.</p>

</body>

</html>

Related Article

0 thoughts on “HTML Comments”

Leave a Reply