A style sheet in the document.
PropertiesNo events.
ExamplesThis example uses the styleSheet object to change the cascading style sheets (CSS) values of inline and imported styles.
<!doctype html> <html> <head> <title></title> <style> BODY {background-color: #CFCFCF;} @import url("otherStyleSheet.css"); </style> <script> window.onload=fnInit; function fnInit() { // Access a rule in the styleSheet, change backgroundColor to blue. var stylesheet = document.styleSheets[0]; var rule = stylesheet.rules[0]; rule.style.backgroundColor = "#0000FF"; // Add a rule for P elements to have yellow backgrounds. stylesheet.addRule("P", "background-color: #FFFF00;"); // Change and imported rule: stylesheet.imports[0].color = "#000000"; } </script> </head> <body> </body> </html>Notes
You can use this object to retrieve style sheet information, 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 can also use it to modify style sheets. You can retrieve a styleSheet object from the styleSheets collection or from the imports collection. Each item in these collections is a style sheet. A styleSheet 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 a style element.
Non Standard MethodsThe styleSheet object has these methods.
Method Description addRule Non standard. Creates a new rule for a style sheet. fireEvent Fires a specified event on the object. Non Standard PropertiesThe styleSheet object has these properties.
Property Description disabled Sets or retrieves a value that indicates whether the user can interact with the object. href Sets or retrieves the URL of the linked style sheet. id Sets or retrieves the string identifying the object. isAlternate Retrieves a value that indicates whether the styleSheet object is an alternative style sheet. isPrefAlternate Retrieves a value that indicates whether the style sheet is the preferred style sheet. media Sets or retrieves the media type. ownerNode Retrieves the node that associates this style sheet with the document. parentStyleSheet Retrieves the style sheet that imported the current style sheets. textAutospace Sets or retrieves the autospacing and narrow space width adjustment of text. title Sets or retrieves the title of the style sheet. type Retrieves the CSS language in which the style sheet is written. See also Related articles CSSOMMicrosoft Developer Network: [Windows Internet Explorer API reference Article]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4