HTML DOM createComment() Method (original) (raw)

Last Updated : 11 Jul, 2025

The **createComment() method is used to create a comment node with some specified text. This property is used to set a text value as a parameter that is of string type.

**Syntax:

document.createComment( text )

**Parameters: This method accepts single parameter text which is optional. This parameter is used to hold the comment string.

**Example: In this example, we will use **createComment() method

html `

DOM createComment() Method

GeeksForGeeks

DOM createComment() Method

Submit

`

**Output:

**Supported Browsers: The browser supported by _DOM createComment() Method properties are listed below: