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

Syntax

stylesheet.deleteRule(index) 

Parameters

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

Return value

Void.

Example

 myStyles.deleteRule(0);

 

Polyfill

The below polyfill will bring support to IE5-IE8.

if (!CSSStyleSheet.prototype.deleteRule) CSSStyleSheet.prototype.deleteRule = CSSStyleSheet.prototype.removeRule;

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.
Obsolete Initial definition

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support 9Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

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

Document Tags and Contributors

Last updated by: anonyco,