

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM removeAttribute() Method
The HTML DOM removeAttribute() method removes the attribute specified in its parameter from the specified element in an HTML document.
Syntax
Following is the syntax −
node.removeAttribute(attributeName);
Example
Let us see an example of removeAttribute() method −
<!DOCTYPE html> <html> <head> <style> html{ height:100%; } body{ text-align:center; color:#fff; background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) center/cover no-repeat; height:100%; } .btn{ background:#0197F6; border:none; height:2rem; border-radius:2px; width:35%; margin:2rem auto; display:block; color:#fff; outline:none; cursor:pointer; } </style> </head> <body> <h1>DOM removeAttribute() method Demo</h1> <p style="color:#db133a;font-size:1.2rem;">Hi! I'm a para element in HTML with some random text</p> <button onclick="remove()" class="btn">Remove Attribute</button> <script> function remove() { document.querySelector("p").removeAttribute("style"); } </script> </body> </html>
Output
This will produce the following output −
Click on “Remove Attribute” button to remove style attribute from <p> element.
- Related Questions & Answers
- HTML DOM addEventListener() Method
- HTML DOM removeAttributeNode() Method
- HTML DOM setAttributeNode() Method
- HTML DOM setNamedItem() Method
- HTML DOM removeNamedItem() Method
- HTML DOM open() Method
- HTML DOM removeEventListener() Method
- HTML DOM replaceChild() Method
- HTML DOM querySelector() Method
- HTML DOM querySelectorAll() Method
- HTML DOM removeChild() Method
- HTML DOM insertAdjacentElement( ) Method
- HTML DOM insertAdjacentHTML( ) Method
- HTML DOM insertAdjacentText( ) Method
- HTML DOM insertBefore( ) Method
Advertisements