Style sheets give you the ability to attach styles to HTML elements. This
allows you to control margins, line spacing, the placement of text and
graphics, colors, font faces, and font sizes. Style sheets make it easier
to create an index because indexing software has only to read the structural
elements rather than the full content of a page. Cascading style sheets,
as defined by the W3C CSS1 specifications, are supported by Microsoft Internet
Explorer 3.0. For more information on CSS1 and Internet Explorer's support
for its properties, see A User's Guide to Style Sheets.
Using the STYLE
element, you can include style information as part of an HTML document
and apply the style to some or all of the text, or you can create a style
sheet as a separate document and attach it to one or more pages on your
Web site. You can use both methods in a single document—creating a style
sheet for all the documents on a Web site, while selectively applying a
special style sheet to text within selected documents. When you include
multiple sets of style information, there may be some contention as to
what style controls the display of an element. CSS1 provides rules of precedence
to decide this.
There are two
ways to place style information inside a document. The first is to assign
a style to an element. For example, here's how to specify a paragraph with
a font size of 20 points.
<P "font-size:
20pt"> This paragraph is in 20-point text.
As Hemingway
once said, "It is a great thing to be able to specify
point sizes,
especially large ones."
This
paragraph is in 20-point text.
As
Hemingway once said, "It is a great thing to be able to specify
point
sizes, especially large ones."
This displays
as:
To place style
information at the top of a page, insert a STYLE block at the top of your
document. The block is placed after the HTML element and before the BODY
element. One type of style information that can be used within the STYLE
element is cascading style sheet (CSS) properties. In the examples for
this section, CSS properties appear within the curly braces after the elements
for which they provide formatting information. (For a full listing of the
CSS properties supported by Microsoft Internet Explorer 3.0, see A User's
Guide to Style Sheets.)
<HTML>
<STYLE>
BODY {background:
white; color: black}
H1 {font:
14pt Arial bold}
P {font: 10pt
Arial; text-indent: 0.5in}
A {text-decoration:
none; color: blue}
</STYLE>
<BODY>
<H1>This
is a headline! In 14-point Arial bold!</H1>
</BODY>
</HTML>
To assign more
than one kind of style information at the same time, separate the styles
with semicolons. For example, to set an entire HTML page to 10-point Times
font, the colors to black on white, and both left and right margins to
one inch, use the following:
<STYLE>
BODY {font:
10pt Times; color: black; background: white;
margin-left:
1in; margin-right: 1in}
</STYLE>
You can attach
an external style sheet to a document or documents on a site. To link a
page to this style sheet, use the LINK element, as in the following example
(where mystyles.css is the external style sheet):
<LINK REL=STYLE
TYPE="text/css" HREF="http://www.mycompany.com/mystyles.css">
The best method
for accomplishing this, however, is to use the STYLE tag.
Note
Notice the use of the TYPE= attribute. This describes the MIME type of
the external file that contains the style information.
The text formatting
features supported by Internet Explorer 3.0 are described fully in A User's
Guide to Style Sheets. |