1. Home
  2. Computing & Technology
  3. Web Design / HTML

Comments in Internet Explorer
Tricks with Comments that Only Work in Microsoft Internet Explorer

By , About.com Guide

The <comment> Element

The <comment> element is an HTML tag that is available only for Internet Explorer (versions 3 and up). This tag allows you to hide things from Internet Explorer.

In browsers other than Internet Explorer, the comment tag is ignored, and all items within it are parsed and displayed as usual.

You use the comment tag like you would any other tag:
<comment>This text is hidden from IE</comment>

It does require a closing tag.

Using Internet Explorer 6 and JavaScript you can read the number of characters in the <comment> with the comment.length property.

The <comment> element is not valid XHTML or HTML.

If you use the <comment> element, you are automatically creating invalid HTML. But as long as that doesn't bother you, it's a great way to hide aspects of your page from Internet Explorer users, while displaying them to users of other browsers.

The <comment></comment> Element
The <!-- comment --> Element

Previous: Conditional Comments

Explore Web Design / HTML
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. About.com Web Design A to Z
  5. Web Design Articles A-H
  6. Web Design/HTML Articles C
  7. Comments in Microsoft Internet Explorer - Conditional Comments and the comment Element>

©2009 About.com, a part of The New York Times Company.

All rights reserved.