The STYLE element is one of the three
methods used to include style information in an HTML document.
The STYLE element is used in the document HEAD
section to indicate style information for the entire document.
If a LINK element exists (used to specify a
style sheet external to the document) in conjunction with the STYLE
element, the rules indicated in the STYLE section should be used
instead of the LINK styles (i.e. it is independent of the style
sheet cascading mechanism.)
For more information on Cascading Style Sheets, please see the
Style Sheet Guide.
NOTE: Because this HEAD element requires
a start and end tag, older browsers may end up displaying the style
content it contains. In order to prevent this, it is STRONGLY
recommended to embed this style information within the HTML Comment
structure (<!-- -->)
Description:
This is a stand-alone attribute which indicates the style reference is
initially non-functional.
Values: NA
Media
2 | 3
| 3.2 | 4
| IE4 | M
| N | O
Required? No
Description:
This attribute is a keyword representing the intended rendering
destination for the style sheet definitions. Multiple destinations
are given delimited by commas.
Values: screen [DEFAULT]
- style information should be used for rendering to computer
screens. print - style information
should be used for rendering to page-centric devices, ie:
printed paper or print preview screen modes. projection - style information
should be used for rendering to transparent projected media
devices. braille - style information
should be used for rendering to braille devices. speech - style information
should be used for rendering to speech synthesizers. all - style information
should be used for rendering to all devices.
Title
2 | 3
| 3.2 | 4
| IE | M
| N | O
Required? No
Description:
This attribute is for use when other style sheet methods are specified.
It allows the browser to build a menu of alternative style sheets
(such as if one or more external Style Sheets are specified through use
of the LINK element.) It may also be used to
identify the Style Sheet in order to allow the user to have control
over turning it on or off.
Values: An alphanumeric string
Type
2 | 3
| 3.2 | 4
| IE3B1 | M
| N4B2 | O
Required? Yes
Description:
This attribute indicates the Internet Media type (MIME) of the
STYLE element content. This MIME type applies to style rules applied within the STYLE
element area as well as to all inline
styles in the current document specified by the STYLE attribute
used in HTML elements.
Values: The current allowed values are
text/css, and text/javascript.
Example
<html>
<head>
<title>Style
Sheet Example</title>
<styleTYPE="text/css">
<!-- h1 { font-weight: bold; font-size: 12pt; line-height: 14pt; font-family: helvetica; font-style: normal
} -->
</style>
</head>
<body>
This is plain text
<h1>This is Heading 1
affected by a style sheet</h1>
This is plain text
</body>
</html>
DTD Note: This element existed in HTML 3.0, but was
much different than it is now. It was then added to the HTML 3.2
recommendation as a place holder until HTML 4.0 which details the usage
of the element.
It appears that more than one STYLE element can be used in
the HEAD area. This may prove useful in areas where Netscape's JSS
proves to be incompatible with CSS.
While the author CAN legally omit using the HTML comment to
encapsulate the Style information, most older browsers will display
the style information in these cases as document content. Authors are
strongly encouraged to use the HTML Comment for the Style element to
prevent this from happening.
For more information on Style Sheets, please see the
Style Sheet Guide.
Browser Peculiarities
Internet Explorer 4.0 only supports the 'screen', 'print' and 'all' Media
attribute values.