CSSStyleSheet.deleteRule()

The CSSStyleSheet.deleteRule() method removes a style rule from the current style sheet object.

Syntax

JavaScript
stylesheet.deleteRule(index) 

Parameters

  • index is a long number representing the position of the rule.

Return value

Void.

Example

JavaScript
myStyles.deleteRule(0);

Specifications

Specification Status Comment
CSS Object Model (CSSOM)
The definition of 'CSSStyleSheet.deleteRule()' in that specification.
Working Draft  
Document Object Model (DOM) Level 2 Style Specification
The definition of 'CSSStyleSheet.deleteRule()' in that specification.
Recommendation Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) (Yes) 9.0 (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)

Legacy browser support

  • Internet Explorer - pre v9

    removeRule([index]);  --  Example: removeRule(); // remove first rule

    Also note the non-standard addRule() and .rules instead of insertRule() and .cssRules respectively.

See also

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/cssstylesheet/deleterule

API CSSOM CSSStyleSheet Method NeedsBrowserCompatibility NeedsMobileBrowserCompatibility Reference