--- title: Comment slug: Web/API/Comment tags: - API - DOM - NeedsTranslation - Reference - TopicStub translation_of: Web/API/Comment ---
{{ ApiRef("DOM") }}

The Comment interface represents textual notations within markup; although it is generally not visually shown, such comments are available to be read in the source view. Comments are represented in HTML and XML as content between '<!--' and '-->'. In XML, the character sequence '--' cannot be used within a comment.

{{InheritanceDiagram}}

Properties

This interface has no specific property, but inherits those of its parent, {{domxref("CharacterData")}}, and indirectly those of {{domxref("Node")}}.

Constructor

{{ domxref("Comment.Comment()", "Comment()") }} {{experimental_inline}}
Returns a Comment object with the parameter as its textual content.

Methods

This interface has no specific method, but inherits those of its parent, {{domxref("CharacterData")}}, and indirectly those of {{domxref("Node")}}.

Specifications

Specification Status Comment
{{SpecName('DOM WHATWG', '#comment', 'Comment')}} {{Spec2('DOM WHATWG')}} Added the constructor.
{{SpecName('DOM3 Core', 'core.html#ID-1728279322', 'Comment')}} {{Spec2('DOM3 Core')}} No change from {{SpecName('DOM2 Core')}}
{{SpecName('DOM2 Core', 'core.html#ID-1728279322', 'Comment')}} {{Spec2('DOM2 Core')}} No change from {{SpecName('DOM1')}}
{{SpecName('DOM1', 'level-one-core.html#ID-1728279322', 'Comment')}} {{Spec2('DOM1')}} Initial definition

Browser compatibility

{{Compat("api.Comment")}}

See also