Learning HTML 3.2 by Examples, section 5 Descriptions of HTML 3.2 tags:

STYLE - style sheets (Not in HTML 2.0!)

Purpose

To specify a style sheet to be used when rendering the document.

Typical rendering

Style sheets, if supported by a browser, can affect the rendering in a multitude of ways. On the other hand, the contents of a STYLE element consists of instructions for rendering and should not be displayed by the browser.

Basic syntax

<STYLE>style info</STYLE>

Possible attributes

None, according to the HTML 3.2 Reference Specification. Notice, however, that various style sheet specifications and proposal involve attributes to STYLE. And in HTML 4.0, the STYLE element is specified so that it has an obligatory TYPE attribute (and some optional attributes).

Allowed context

The head section.

Contents

Style information. The syntax and semantics is to be defined separately.

Technically, these elements are defined with CDATA as the content type. As a result they may contain only SGML characters. All markup characters or delimiters are ignored and passed as data to the application, except for the character pair </ followed immediately by a letter (a - z, A - Z), This means that the end tag of the element (or of an element in which it is nested) is recognized.

It is legal, and recommendable, to use the HTML comment delimiters <!-- and --> around the contents of a STYLE element. The reason is that by doing so you ensure that old browsers (ignorant of STYLE) will not display the contents.

Examples

This example uses a very simple style sheet according to CSS1, to specify that some sans-serif font be used when rendering the document, except for U elements, which are to be rendered in a serif font (in addition to being underlined).

Example STYLE-1.html:

<HEAD>
<STYLE><!--
BODY { font-family: sans-serif }
U    { font-family: serif }
--></STYLE>
</HEAD>
<BODY>
Sample text 1.<BR>
<U>Sample text 2.</U>
</BODY>

Notes

According to the HTML 3.2 Reference Specification, the STYLE element is just a place holder for the introduction of style sheets in future versions of HTML.

Date of last update: 2010-12-16.
This page belongs to the free information site IT and communication, section Web authoring and surfing, by Jukka "Yucca" Korpela.