style (element) | NN 6 IE 4 DOM 1 | |||||||||||
The style element object reflects the style HTML element. This object is separate from the style object that is accessed as a property of virtually every element in a document. The style element object is generated in a document via the <style> tag, which can have a unique ID value assigned to it; the style (property) object contains all the style properties and their current values as set for a particular element. |
||||||||||||
HTML Equivalent | ||||||||||||
<style> |
||||||||||||
Object Model Reference | ||||||||||||
[window.]document.getElementById("elementID")
|
||||||||||||
Object-Specific Properties | ||||||||||||
|
||||||||||||
Object-Specific Methods | ||||||||||||
None. |
||||||||||||
Object-Specific Event Handler Properties | ||||||||||||
|
disabled | NN 6 IE 4 DOM 1 |
Read/Write | |
Specifies whether rules in the style sheet should be applied to their selected elements. Although the corresponding disabled attribute does not work in Internet Explorer 4, setting the disabled property to true does, in fact, turn off the entire style sheet. During page authoring, you can create a button that toggles style sheets on and off to see how the page looks in all types of browsers. |
|
Example | |
document.getElementById("mainStyle").disabled = true; |
|
Value | |
Boolean value: true | false. |
|
Default | |
false |
media | NN 6 IE 4 DOM 1 |
Read/Write | |
Indicates the intended output device for the rules of the style element. The media property looks forward to the day when browsers are able to tailor content to specific kinds of devices such as pocket computers, text-to-speech digitizers, or fuzzy television sets. |
|
Example | |
document.getElementById("myStyle").media = "print"; |
|
Value | |
Any one of the following constant values as a string: all | print | screen. |
|
Default | |
all |
sheet | NN 6 IE n/a DOM n/a |
Read-only | |
Returns a styleSheet object (W3C DOM type CSSStyleSheet) representing the style sheet defined by the style element. This is an alternate (and nonstandard) way to reference a styleSheet object. The document.styleSheets collection is a better approach. |
|
Example | |
var oneSheet = document.getElementById("myStyle").sheet; |
|
Value | |
Reference to a styleSheet object (W3C DOM type CSSStyleSheet). |
|
Default | |
None. |
styleSheet | NN n/a IE 6(Win) DOM n/a |
Read-only | |
Returns a styleSheet object representing the style sheet defined by the style element. This is property is present, but doesn't seem to be officially supported. The document.styleSheets collection is a better approach. |
|
Example | |
var oneSheet = document.getElementById("myStyle").styleSheet; |
|
Value | |
Reference to a styleSheet object. |
|
Default | |
None. |
type | NN 6 IE 4 DOM 1 |
Read/Write | |
This is the style sheet MIME type specified by the type attribute of the style element. |
|
Example | |
if (document.getElementById("myStyle").type == "text/css") { // unlikely to be anything else } |
|
Value | |
MIME type string. |
|
Default | |
text/css |