This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
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, like inside SVG or MathML markup, the character sequence -- cannot be used within a comment.
This interface has no specific property, but inherits those of its parent, CharacterData, and indirectly those of Node.
Comment()Returns a new Comment object with the parameter as its textual content. If not present, its default value is the empty string, ''.
This interface has no specific method, but inherits those of its parent, CharacterData, and indirectly those of Node.
| Specification |
|---|
| DOM> # interface-comment> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
Comment |
29 | 16 | 24 | 16 | 8 | 29 | 24 | 16 | 8 | 2.0 | 4.4 | 8 |
Comment |
1 | 12 | 1 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Comment