WebDevelopersNotes logo

home-icon Home / HTML / HTML primer – HTML Comment Tags

HTML primer – HTML Comment Tags

HTML primer - HTML Comment Tags

As your HTML pages grow, so will their complexity. Maintaining such complex pages can be quite a problem if there is no way to add documentation to these files. Fortunately, HTML provides tags through which you can add comments to various sections of your scripts. Take my advice, use the comments tags generously in your documents. When you look back at your files after a few months you shall be able to decipher the code much faster.

The starting comment tag is <!– (that’s the ‘lesser than’ sign followed by an exclamation mark and two dashes) and the ending tag is –>.

The browser does not display any text placed between these tags. Try this out yourself. Open a new document in Notepad and type the following and check the results in a browser.

<HTML>
<HEAD>
<TITLE>Testing Comment tags in HTMLs</TITLE>
</HEAD>
<BODY>
I am visible.
<!-- I am not displayed by the browser -->
</BODY>
</HTML>

Your comments can span multiple lines as in:

<!--
This comment 
spans multiple lines
making the code easy to read
after a few months.
-->

Comment tags are invaluable if you work (or are planning to work) in a group. Your colleagues will be able to understand and decipher your code faster if you have used comment tags judiciously.

Sponsored Links

Your comments
Star icon IMPORTANT Have a question / problem? Click here to ask an expert.

Joke - Eat, Sleep and Code

Sponsored Links

Tips

How do I view a deleted web page?
Is there a way to view a deleted web page - one that is no longer available? Yes there is and the solution is quite simple. [more...]

Fact

Google owned URL shortening service, goo.gl, is a domain hack which uses the country code TLD of Greenland. [more...]

We use cookies to give you the best possible website experience. By using WebDevelopersNotes.com, you agree to our Privacy Policy