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 September 2015.

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

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
deleteRule

Legend

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

Full support
Full support