CSSGroupingRule: deleteRule() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.

The deleteRule() method of the CSSGroupingRule interface removes a CSS rule from a list of child CSS rules.

Syntax

js
deleteRule(index)

Parameters

index

The index of the rule to delete.

Return value

None (undefined).

Exceptions

IndexSizeError DOMException

Thrown if index is greater than or equal to the number of child CSS rules.

InvalidStateError DOMException

Thrown if the rule being removed is an @namespace at-rule, and the list of child CSS rules contains anything other than @import at-rules and @namespace at-rules.

Examples

js
let myRules = document.styleSheets[0].cssRules;
myRules[0].deleteRule(2); /* deletes the rule at index 2 */

Specifications

Specification
CSS Object Model (CSSOM)
# dom-cssgroupingrule-deleterule

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
deleteRule
Chrome – Full support
Chrome 45 (Release date: 2015-09-01)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 20 (Release date: 2013-04-02)
footnote Full support
Opera – Full support
Opera 32 (Release date: 2015-09-15)
footnote Full support
Safari – Full support
Safari 3 (Release date: 2007-10-26)
footnote Full support
Chrome Android – Full support
Chrome Android 45 (Release date: 2015-09-01)
footnote Full support
Firefox for Android – Full support
Firefox for Android 20 (Release date: 2013-04-02)
footnote Full support
Opera Android – Full support
Opera Android 32 (Release date: 2015-09-23)
footnote Full support
Safari on iOS – Full support
Safari on iOS 2 (Release date: 2008-07-11)
footnote Full support
Samsung Internet – Full support
Samsung Internet 5 (Release date: 2016-12-15)
footnote Full support
WebView Android – Full support
WebView Android 45 (Release date: 2015-09-01)
footnote Full support
WebView on iOS – Full support
WebView on iOS 2 (Release date: 2008-07-11)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support