style element | style object
Specifies a style sheet for a document.
![]() |
DOM Information
Inheritance Hierarchy
Members
The style object has these types of members:
Events
The style object has these events.
| Event | Description |
|---|---|
| abort |
Fires when the user aborts the download. |
| change |
Fires when the contents of the object or selection have changed. |
| error |
Fires when an error occurs during object loading. |
| input |
Occurs when the text content of an element is changed through the user interface. |
| load |
Fires immediately after the client loads the object. |
| onselect |
Fires when the current selection changes. |
| readystatechange |
Fires when the state of the object has changed. |
| reset |
Fires when the user resets a form. |
Methods
The style object has these methods.
| Method | Description |
|---|---|
| addBehavior |
Attaches a behavior to the element. |
| applyElement |
Makes the element either a child or parent of another element. |
| clearAttributes |
Removes all attributes and values from the object. |
| componentFromPoint |
Returns the component located at the specified coordinates via certain events. |
| dragDrop |
Initiates a drag event. |
| getAttributeNodeNS |
Gets an attribute object that matches the specified namespace and name. |
| getAttributeNS |
Gets the value of the specified attribute within the specified namespace. |
| getElementsByClassName |
Gets a collection of objects that are based on the value of the class attribute. |
| getElementsByTagNameNS |
Gets a collection of objects that are based on the specified element names within a specified namespace. |
| hasAttributeNS |
Determines whether an attribute that has the specified namespace and name exists. |
| msMatchesSelector |
Determines whether an object matches the specified selector. |
| removeAttributeNS |
Removes the specified attribute from the object. |
| removeBehavior |
Detaches a behavior from the element. |
| replaceAdjacentText |
Replaces the text adjacent to the element. |
| setAttributeNodeNS |
Sets an attribute object as part of the object. |
| setAttributeNS |
Sets the value of the specified attribute within the specified namespace. |
| setCapture |
Sets the mouse capture to the object that belongs to the current document. |
Properties
The style object has these properties.
| Property | Description |
|---|---|
|
Gets a value indicating whether the object can contain child objects. | |
|
Returns a reference to the constructor of an object. | |
|
Sets or retrieves a value that indicates whether the user can interact with the object. | |
|
Sets or retrieves the string identifying the object. | |
|
Sets or retrieves the media type. | |
|
Gets the namespace defined for the element. This property is not supported for Windows Store apps using JavaScript. | |
|
Gets the CSS style sheet that is associated with the object. | |
|
Retrieves an interface pointer that provides access to the style sheet object's properties and methods. | |
|
Sets or gets the URN specified in the namespace declaration. This property is not supported for Windows Store apps using JavaScript. | |
|
Retrieves the CSS language in which the style sheet is written. |
Standards information
- HTML 4.01 Specification, Section 14.2.3
Remarks
The style element should appear in the head section of an HTML document. Microsoft Internet Explorer 6 and later permit multiple style blocks.
Examples
This example encloses style declarations in the style element and changes one of those settings using the style object.
<head>
<style>
body {
background-color: white;
color: black;
}
h1 {
font: 8pt Arial bold;
}
p {
font: 10pt Arial;
text-indent: 0.5in;
}
a {
text-decoration: none;
color: blue;
}
</style>
<script type="text/javascript">
oParagraph.style.fontSize = 14;
</script>
</head>
<body>
<p>Sample Paragraph Text</p>
</body>
Send comments about this topic to Microsoft
Build date: 11/28/2012

