Web Site Primer

HTML · Web Design · Color Charts · & More!

HTML Markup: Comment Tag

Originally Published: 2001-10-13
Updated: 2006

There are times when you may need to share notations, or comments, while editing and working on an HTML document. Helpfully enough, HTML provides us with a specialized tag just for that purpose. This article will delve into (author) comment tag.

The comment tag was introduced very early through earlier versions of HTML. This tag is like other HTML tags, in terms of using an opening [<] and closing [>] brackets. After that, the comment tag becomes unique due to its specialized use by Web page authors - whom the tag was created for in the first place.

As you work on your text file, you may find yourself losing your place. All that type, quotation marks, equal signs, and brackets to wade through! How can one keep track of where they are at or find a certain place in their file while editing? It was due to this that the comment tag came to exist.

Since this is a specialized tag, created for use in editing and keeping track of changes, or whatever comments the Web page author feels a need to share, comment tags take on a different appearance within most HTML editors. Other HTML tags may appear in a shade of green in a HTML editor, attributes (for those tags) appearing in blue text to help the author's eyes keep track. Comment tags' contents, however, may appear in a gray-color italic text. This appearance allows the Web page's author to scan through the contents for the particular section, or comment tag, sought.

Comment Markup

<!--TEXT-->
Specialized Singlet tag; no shortcut
Use: Surrounds text that is a comment, or notation, for the Web page author's use or reference.
Suggestions: Dashes [-] should match on both sides of the enclosed text. If hsaring more than one set of dashes, the dashes should be in multiples of two (or even in number).

Example of markup:
<!--Share about past misuse-->

Appearance on the Web
(will appear as dark green text within your browser of choice):

If you don't see any green text, don't worry. This just means that the comment tag is working properly as these are only visible when looking at the raw HTML document.

Online HTML editors

Some online editors may refuse, or not accept, contents sharing comment tagged text. For example, at last check back in 2003, Yahoo! Groups online Safe-HTML editor (offered for Group Owners to use) would not accept commented text or what it thought looked like JavaScript.

You have two options in those instances. Use the comments tags in the document through another HTML editor. Then cut and paste, or copy, the files over to the online editor. While doing this process, you can:

  1. skip over the comments contained in that file while copying over the contents, or
  2. go through and delete out the comments before clicking SAVE on the online editor.

The above two options would allow you to keep a copy of the file, on your hard drive, with the comments and notations for your own use.

Misuse of Comment Tags

Some people will do almost anything to achieve decent rankings on a search engine; even misusing some of the HTML tags to help toward this goal. One of the tags that became misused, and abused, was the comment tag.

Part of Search Engine Optimization is observation of trends in the search engines. It didn't take long before it was noticed that text in the comment tags was being indexed in with the rest of the page's contents. This lead to some people using comment tags that were not only keyword rich but, at times, stuffed to the hilt with keywords.

Before thinking I am sharing a neat and nifty trick for people to implement in your pages - I am not. This trick only worked prior to 2000. Since that time many of the major search engines, like Google and Yahoo! Search, have tweaked their spiders to ignore comment tags and their contents. Logical in a way as these snippets of text were not supposed to be of use to anyone but the Web page's author.


Related Articles:


straight to the top