HTML DOM createAttribute() Method (original) (raw)
Last Updated : 11 Jul, 2025
This **createAttribute() method is used to create an attribute with the specified name and returns the attribute object. The attribute.value property is used to set the value of the attribute and the element.setAttribute() method is used to create a new attribute for an element. This method() contains the name of the created attribute as a parameter value.
**Syntax:
document.createAttribute( attributename )
**Example: In this example, we will use the **createAttribute() method.
HTML `
DOM createAttribute MethodGeeksforGeeks
DOM createAttribute() Method
Submit`
**Output:

**Example 2: In this example, we will use the **createAttribute() method.
html `
GeeksforGeeks
DOM createAttribute() Method
Visit GeeksForGeeks...Submit
`
**Output:

**Supported Browsers: The browser supported by **DOM createAttribute() method are listed below: