StyleSheet.addRule() (Method)

A method for adding a rule to a style sheet.


JScript - 3.0
Internet Explorer - 4.0
JavaScript syntax:IEmyStyleSheet.addRule(aSelector, aStyle)
IEmyStyleSheet.addRule(aSelector, aStyle, anIndex)
Argument list:anIndexA index in the collection where the new rule should be inserted
aSelectorThe style rule selector string
aStyleA series of style settings for this rule

This method allows individual rules to be added to a style sheet. You may want to control the precedence of the rules, and so the optional index value can be used to determine where in the collection of rules the new rule is to be inserted.

If the index is omitted, the new rule is simply appended to the style sheet.

You can override rules as long as you are not changing the type of rule being defined. Positional rules must always be overridden by a new positioning rule and cannot be changed to an appearance rule and vice versa.

See also:Document.createStyleSheet(), Hierarchy of objects, StyleSheet.removeRule(), StyleSheet.rules[]