
This interface provides access to an object representing a single style sheet in the document.
The styleSheet object represents an instance of the STYLE or LINK tag with a relationship (rel attribute) of the STYLESHEET object.
You use the object to retrieve information about the style sheet, such as the URL of the source file for the style sheet and the element in the document that owns (defines) the style sheet. You also use the object to modify the style sheet.
You retrieve a pointer to the style sheet object by using the IHTMLDocument2::get_styleSheets method. You can retrieve a collection of all styleSheets in the document by using the IHTMLStyleSheet::get_imports method. Each item in the collection is a style sheet. A style sheet object is available for a style sheet only if it is included in a document with a STYLE or LINK element, or with an @import statement in the STYLE element.
IHTMLStyleSheet Methods
HRESULT addImport(
BSTR bstrURL,
long lIndex,
long *plIndex
);
Adds a style sheet to the imports collection for the given style sheet.
HRESULT addRule(
BSTR bstrSelector,
BSTR bstrStyle,
long lIndex,
long *plNewIndex
);
Creates a new style rule using the given selector and style assignment.
HRESULT get_cssText(
BSTR *p
);
Retrieves a string of the rules set in the style sheet defined in the CSS format as it would look, if the style sheet were saved.
HRESULT get_disabled(
VARIANT_BOOL *p
);
Determines whether the style sheet is enabled or disabled. "False" for style sheets that do not specify a title and that are not currently selected.
The value of this property can change per media-dependent style sheets. The application of individual style sheets can be turned on and off dynamically. Note that the value of this property is also controlled by whether titled style sheets are applied.
See also put_disabled
HRESULT get_href(
BSTR *p
);
Retrieves the URL of a linked style sheet.
See also put_href
HRESULT get_id(
BSTR *p
);
Retrieves the identifier of the style sheet.
HRESULT get_imports(
IHTMLStyleSheetsCollection **p
);
Retrieves a zero-based collection of all the imported style sheets defined for the given styleSheet object. An imported style sheet is one that is brought into the document using the CSS @import attribute.
HRESULT get_media(
BSTR *p
);
Receives the string that indicates which media this style applies to.
See also put_media
HRESULT get_owningElement(
IHTMLElement **p
);
Retrieves the element that is next in the HTML hierarchy. This usually contains the STYLE or LINK that defined the style sheet.
See also IHTMLElement
HRESULT get_parentStyleSheet(
IHTMLStyleSheet **p
);
Retrieves an interface pointer to the styleSheet object that imported the current style sheet. This property is intended for imported styleSheets.
HRESULT get_readOnly(
VARIANT_BOOL *p
);
Indicates whether the rule object can be edited.
HRESULT get_rules(
IHTMLStyleSheetRulesCollection **p
);
Retrieves an IHTMLStyleSheetRulesCollection pointer to the collection of the rules in this styleSheet. If there are no rules, the length of the collection returned is zero.
HRESULT get_title(
BSTR *p
);
Retrieves the title of the styleSheet.
The application of individual style sheets can be turned on and off dynamically. Note that the value of this property is also controlled by whether titled style sheets are applied.
See also put_title
HRESULT get_type(
BSTR *p
);
Retrieves the CSS language the style sheet is written in.
HRESULT put_disabled(
VARIANT_BOOL v
);
Enables or disables the style sheet.
See also get_disabled
HRESULT put_href(
BSTR v
);
Sets the URL of a linked styleSheet; that is, it is part of a LINK element.
See also get_href
HRESULT put_media(
BSTR v
);
Sets the string that indicates which media this style element applies to. See IHTMLLinkElement::put_media for values.
See also get_media
HRESULT put_title(
BSTR v
);
Sets the title of the styleSheet element.
See also get_title
HRESULT removeImport(
long lIndex
);
Removes the imported style sheet by ordinal position in the imports collection based on the value of the index passed in.
HRESULT removeRule(
long lIndex
);
Removes the rule by ordinal position based on the value of the index passed in. The rule is deleted from the style sheet, and the document is updated to reflect any changes.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.