HTML 4 Comments Tag

Also see HTML5 <Comments> Tag.

This page contains information about the HTML 4 version of this element. For a more up to date version, see HTML5 <Comments> Tag.

The HTML 'comments' tag is used for creating comments within your HTML code.

Comments aren't displayed in the browser - they are simply there for the programmer's benefit. Comments can assist you, the HTML programmer, because you can write notes to yourself that explain what the code does. This is especially useful when you have a lot of code.

HTML comments are often used in conjunction with JavaScript. Programmers surround their JavaScript code with HTML comments. The HTML comments tell browsers that don't support JavaScript (or with JavaScript disabled) to ignore the code in between. This prevents the code from being displayed to your users.

You can see an example here.




Try it Yourself!

Modify the code below, then click Update. See below for attributes.

HTML5 Tags

The information on this page is based on HTML version 4.01. Most modern browsers now support HTML5, which is the next version of HTML after HTML 4.01.

See HTML5 <Comments> Tag for the HTML5 version of the above element.

Also see this list of HTML 5 tags for the latest version of HTML.