InsertRule

ICSSStyleSheet.InsertRule method

The CSSStyleSheet.insertRule() method inserts a new CSS rule into the current style sheet, with some restrictions.

Note: Although insertRule() is exclusively a method of CSSStyleSheet, it actually inserts the rule into CSSStyleSheet.cssRules — its internal CSSRuleList.

public long InsertRule(string rule, int index)
Parameter Type Description
rule String A String containing the rule to be inserted. What the inserted rule must contain depends on its type:
index Int32 A positive integer less than or equal to stylesheet.cssRules.length, representing the newly inserted rule’s position in CSSStyleSheet.cssRules. The default is 0.

Return Value

The newly inserted rule’s index within the stylesheet’s rule-list.

Remarks

CSSOM defines APIs (including generic parsing and serialization rules) for Media Queries, Selectors, and of course CSS itself.

Reference

CSS Working Group - The CSS Working Group is the W3C working group chartered to develop Cascading Style Sheets (CSS).CSS Object Model (CSSOM) - CSSOM defines APIs (including generic parsing and serialization rules) for Media Queries, Selectors, and of course CSS itself.CSS Object Model (CSSOM) # dom-cssstylesheet-insertrule – The CSSOM definition.

See Also