addRule Method

Microsoft FrontPage Visual Basic

addRule Method

Creates a new style rule for a cascading style sheet, and returns a Long that represents the index of the new style rule in the rules collection.

expression.addRule(bstrSelector, bstrStyle, lIndex)

expression    Required. An expression that returns one of the objects in the Applies To list.

bstrSelector    Required String. Specifies the selector for the new rule. Single contextual selectors are valid. For example, "DIV P B" is a valid contextual selector.

bstrStyle    Required String. Specifies the style assignments for this style rule. This style takes the same form as an inline style specification. For example, "color:blue" is a valid style parameter.

lIndex    Optional Long. Specifies the location in the rules collection to which to add the new style rule. If an index is not provided, the rule is added to the end of the collection by default.

Remarks

The addRule method only adds cascading style sheet rules to STYLE elements in a page and does not modify external style sheets referenced.

Example

The following example adds a cascading style sheet rule that sets the color of the text in the P element.

    Dim objCSS As FPHTMLStyleSheet

Set objCSS = ActiveDocument.styleSheets(1)
objCSS.addRule "p", "color: rgb(255,153,0)"