Hello, world!

Comments HTML

In the HTML Comments section of the HTML Tutorial you will learn how to work with comments inside an html document. Applying the HTML comment <!-- … --> tag allows you to include comments into an HTML document. Comments are codes which are completely ignored by the browser meaning they will not be displayed. This can help you to document your HTML such as revision histories, indicating sections of a document and notes about how to improve it.


 
Syntax html comments:
<!-- text -->
 
HTML code example html comments:
 <!-- How to use a HTML comment tag -->
<p>Paragraph</p>
 
HTML output html comments:
{!-- How to use a HTML comment tag --}
{p}Paragraph{/p}
 
Conditional Comments
Conditional comments are conditional instructions that only works on Microsoft Internet Explorer versions 5 onwards in HTML source code.  
Conditional comments are ignored by other browsers.
 
HTML code example conditional comments:
<!DOCTYPE html><html>
<head>  
<title>How to use Conditional Comments</title>
 
<!--[if IE 6]>
   This is IE 6
<![endif]-->
 
</head>
<body>
<p>Document Text.....</p>
</body>
</html>
 
Valid vs Invalid Comments
HTML Comment element is written using both start and closing tags.
You must properly nest start and closing tags, that denotes a comment cannot put within another comment.
Make certain that no spacwea contain in the start-of-comment string
 
HTML code example valid vs invalid comments:
<!--   How to make Valid Comment -->
<p>Document Text.....</p>
 
HTML output valid vs invalid comments:
{!--   How to make Valid Comment --}
{p}Document Text.....{/p}
 
Space between the left angle bracket and the exclamation mark is not allowed.
 
Multiline Comments
HTML supports Multi-line comments,  
To apply this, put the special beginning tag <! ending tag --> positioned before the first line and end of the last line.
 
HTML code example multiline comments:
<!--   
HTML supports Multi-line comments where you can
extent through as many as lines you like.
-->
<p>Document text.....</p>
 
HTML output multiline comments:
{!--   
HTML supports Multi-line comments where you can
extent through as many as lines you like.
--}
{p}Document text.....{/p}
 
Using Comment Tag
The <comment> tag is supported only by few browsers to comment a part of code.
 
HTML code example comment tag:
<p>This is <comment>not</comment> Internet Explorer.</p>
 
HTML output comment tag:
{p}This is {comment}not{/comment} Internet Explorer.{/p}
 
Commenting Script Code
HTML comments are designed to comment out code.  
And when you are using JavaScript or VB Script in your HTML code it is important to put that code inside the HTML comment correctly, considering the old browser to function appropriately.  
 
HTML code example commenting script code:
<!DOCTYPE html><html>
<head>
<title> How to Comment Script Code</title>
<script>
<!--
   document.write("Commenting Script Code")
//-->
</script>
</head>
<body>
<p>Commenting Script Code</p>
</body>
</html>
 
Commenting Style Sheets
HTML comments are intended to comment out code.  
When you are using Casecading Style Sheet (CSS) in your HTML code it is important to put that code within the HTML comment correctly.  Commenting out on this section will help you if you are trying out with some effects.
 
HTML code example commenting style sheets:
<!DOCTYPE html><html>  
<head>
<title>How to Comment Style Sheets</title>
<style>
<!--
.example {
  border:4px solid #231F92;
}
//-->
</style>
</head>
<body>
<div class="example"> How to Comment Style Sheets </div>
</body>
</html>