CSS | Style Declaration removeProperty() Method
The removeProperty() method is used to remove the existing CSS property.
Syntax: It is used to remove the specified CSS property.
object.removeProperty(propertyname)
Parameters: It accepts a single parameter:
- propertyname: It is a required parameter that contains a string which represents the name of the property to be removed.
Return value: It returns the value of the removed property in the form of string.
Example: To show the working of the removeProperty() method:
<html> <head> <title> CSS | Style Declaration removeProperty() Method </title> <style> body { text-align: center; } h1 { color: green; } #p1 { color: green; font-size: 20; background-color: black; } </style> </head> <body> <h1>GeeksforGeeks</h1> <p id="p1"> removeProperty() Method</p> <button onclick="myFunction()"> Remove property </button> <p id="gfg"></p> <!-- Script to remove the property --> <script> function myFunction() { var x = document.styleSheets[ 0].cssRules[2].style; // Remove the background color property. var propertyRemoved = x.removeProperty( "background-color"); document.getElementById( "gfg").innerHTML = "Property removed is background-color i.e." + propertyRemoved; } </script> </body> </html> |
Output:
- Before clicking on the button:

- After clicking on the button:

Supported Browsers: The browsers supported by Style Declaration removeProperty() Method are listed below:
- Google Chrome
- Internet Explorer 9.0
- Firefox
- Opera
- Safari
Recommended Posts:
- TypeScript Ambients Declaration
- Difference between function expression vs declaration in JavaScript
- HTML | Style Tag
- How to style a dropdown using CSS?
- How to style a checkbox using CSS?
- p5.js | style() Function
- AngularJS | ng-style Directive
- CSS | outline-style Property
- How to create a style tag using JavaScript?
- CSS | border-right-style Property
- HTML | style attribute
- CSS | transform-style Property
- HTML | DOM Style top Property
- HTML | DOM Style right Property
- How to set CSS style to half of a character ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



