Skip to: content, navigation

by Ian Lloyd

comment (HTML element)

Spec
Depr. Empty Version
Yes No N/A
Browser support full matrix
IE5.5+ FF2 Saf3 Op9.5
Full None None None

Example

Here’s an example of how comment might be used:

<p><strike>The guy is a fool.</strike><comment>I obviously
misunderstood what he was saying at first!</comment> The guy is an
absolute genius. What was I thinking?</p>
Type
inline element
Contains
inline elements only
Contained by
block-level elements, inline elements

Description

The comment element is a non-standard and little-supported element that’s used to add comments to markup. It has just one attribute—data—that points to a web page that provides further information about the comment. Moving forward, this element shouldn’t be used. Instead, use the standard HTML comment syntax of <!-- comment here -->.

Use This for…

This element can be applied to any text content.

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0None
1.5None
2.0None
Safari1.3None
2.0None
3.0None
Opera9.2None
9.5None

All the browsers tested ignored the comment element in the example HTML above; they rendered the text it contained as shown in Figure 1.

Figure 1. A browser’s interpretation of the comment element Example of comment element

Instead of comment, you should use this approach to create code comments:

<p><strike>The guy is a fool.</strike><!-- I obviously
misunderstood what he was saying at first! --> The guy is an
absolute genius. What was I thinking?</p>

Related Reading

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters