Met Element Setattribute
# HTML DOM setAttribute() Method
[ Element Object](#)
## Example
Set the type attribute of an input element:
document.getElementsByTagName("INPUT").setAttribute("type","button");
Before setting the attribute:
After setting the attribute:
[Try it Β»](#)
## Definition and Usage
The setAttribute() method creates or changes a new attribute.
If the specified attribute already exists, only the value is set.
* * *
## Browser Support

The setAttribute() method is supported by all major browsers.
Internet Explorer 8 and earlier versions do not support this method.
* * *
## Syntax
_element_.setAttribute(_attributename_,_attributevalue_)
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| _attributename_ | String | Required. The name of the attribute you want to add. |
| _attributevalue_ | String | Required. The value of the attribute you want to add. |
## Return Value
No return value.
## Technical Details
| DOM Version | Core Level 1 Element Object |
| --- |
* * Element Object](#)
YouTip