style element | style object
[This documentation is preliminary and is subject to change.]
Specifies a style sheet for a document.
![]() |
Standards information
- HTML 4.01 Specification, Section 14.2.3
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
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.
- 12/29/2011
- Rich Carlson
- 5/28/2012
- yecril
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 ...
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 ...
- 6/21/2010
- Mr. Raymond Kenneth Petry
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
- 1/4/2010
- Michael Quinlan
