5 out of 18 rated this helpful Rate this topic

STYLE Element | style Object

.NET Framework 3.0

Specifies a style sheet for a document.

Members Table

The following table lists the members exposed by the style object.

Attributes/Properties

Attribute Property Description
canHaveChildren Gets a value indicating whether the object can contain child objects.
constructor Returns a reference to the constructor of an object.
DISABLED disabled Sets or retrieves a value that indicates whether the user can interact with the object.
ID id Sets or retrieves the string identifying the object.
MEDIA media Gets or sets the media type.
scopeName Gets the namespace defined for the element.
sheet New for Windows Internet Explorer 9  Gets the Cascading Style Sheets (CSS) style sheet that is associated with the object.
styleSheet Retrieves an interface pointer that provides access to the style sheet object's properties and methods.
tagUrn Sets or gets the Uniform Resource Name (URN) specified in the namespace declaration.

Collections

Collection Description
behaviorUrns Returns a collection of Uniform Resource Name (URN) strings identifying the behaviors attached to the element.

Events

Event Event Property Description
abort New for Internet Explorer 9  onabort Fires when the user aborts the download.
change New for Internet Explorer 9  onchange Fires when the contents of the object or selection have changed.
error onerror Fires when an error occurs during object loading.
input New for Internet Explorer 9  oninput Occurs when the text content of an element is changed through the user interface.
load onload Fires immediately after the client loads the object.
readystatechange onreadystatechange Fires when the state of the object has changed.
onreset New for Internet Explorer 9  Fires when the user resets a form.
select New for Internet Explorer 9  onselect Fires when the current selection changes.

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 New for Internet Explorer 9  Gets an attribute object that matches the specified namespace and name.
getAttributeNS New for Internet Explorer 9  Gets the value of the specified attribute within the specified namespace.
getElementsByClassName New for Internet Explorer 9  Gets a collection of objects that are based on the value of the CLASS attribute.
getElementsByTagNameNS New for Internet Explorer 9  Gets a collection of objects that are based on the specified element names within a specified namespace.
hasAttributeNS New for Internet Explorer 9  Determines whether an attribute that has the specified namespace and name exists.
msMatchesSelector New for Internet Explorer 9  Determines whether an object matches the specified selector.
removeAttributeNS New for Internet Explorer 9  Removes the specified attribute from the object.
removeBehavior Detaches a behavior from the element.
replaceAdjacentText Replaces the text adjacent to the element.
setAttributeNodeNS New for Internet Explorer 9  Sets an attribute object as part of the object.
setAttributeNS New for Internet Explorer 9  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.

Prototypes

Object Description
HTMLStyleElement Constructor Defines the properties and methods inherited by objects in the HTMLStyleElement Constructor prototype chain.

Styles

Style attribute Style property Description
TYPE type Retrieves the CSS language in which the style sheet is written.

Remarks

The STYLE element should appear in the HEAD section of an HTML document. Microsoft Internet Explorer 4.0 and later permit multiple style blocks.

This element is not rendered.

This element requires a closing tag.

Example

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>
    oParagraph.style.fontSize = 14;
</SCRIPT>
</HEAD>
<BODY>
<P>Sample Paragraph Text</P>
</BODY>

Standards Information

This object is defined in HTML 3.2.

Did you find this helpful?
(2000 characters remaining)
Community Content Add
Annotations FAQ
And Someone, Somewhere thinks this is OK?
All other browsers support way more than 31 <style></style> tags! This is just criminal! There seems to be no acknowledgement that this is a serious BUG! $0$0 $0 $0Yet another reason to switch to Chrome or Firefox!$0 $0$0 $0
restrictions - multiple selectors
N.B. It appears (for IE-8), that--
 
Only the first of multiple selectors gets parameter updates.

e.g. 
In <STYLE id=sayStyle> DL DL DT, DL DL .LOG {margin:0,0,0,-90;text-indent:0}</STYLE>
DL DL DT gets the subsequent 'user-desired' changes to the sayStyle.styleSheet.rules[0].style.marginLeft ...
All style tags after the first 30 style tags on an HTML page are not applied in Internet Explorer
http://support.microsoft.com/kb/262161