Back to Content

CSSStyleSheet: removeRule() method

files/en-us/web/api/cssstylesheet/removerule/index.md

latest1.2 KB
Original Source

{{APIRef("CSSOM")}}{{deprecated_header}}

The obsolete {{domxref("CSSStyleSheet")}} method removeRule() removes a rule from the stylesheet object. It is functionally identical to the standard, preferred method {{domxref("CSSStyleSheet.deleteRule", "deleteRule()")}}.

[!NOTE] This is a legacy method which has been replaced by the standard method {{domxref("CSSStyleSheet.deleteRule", "deleteRule()")}}. You should use that instead.

Syntax

js-nolint
removeRule(index)

Parameters

  • index
    • : The index into the stylesheet's {{domxref("CSSRuleList")}} indicating the rule to be removed.

Return value

None ({{jsxref("undefined")}}).

Examples

This example removes the first rule from the stylesheet myStyles.

js
myStyles.removeRule(0);

You can rewrite this to use the standard deleteRule() method very easily:

js
myStyles.deleteRule(0);

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also