7 out of 21 rated this helpful - Rate this topic

style element | style object

[This documentation is preliminary and is subject to change.]

Specifies a style sheet for a document.

HTML 4.01 Specification, Section 14.2.3

Standards information

DOM Information

Inheritance Hierarchy

 Node
  Element
   HTMLElement
     style

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.

The STYLE element should appear in the HEAD section of an HTML document. Multiple style blocks are permitted.

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

 

 

Build date: 3/8/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
no children

If object.tagName == "STYLE" then object.firstChild is null, even if the STYLE element has inline content.

The inline content is available as object.innerHTML but that will contain the markup comments if given in the original.

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