![]() |
![]() |
Style sheets give you the ability to attach styles to HTML pages, letting you control margins, line spacing, the placement of elements, colors, fonts 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 are supported by Microsoft Internet Explorer 3.0.
You can include a style sheet 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. And you can use both methods in a single documentcreating a style sheet for all the documents on a Web site, while selectively applying a special style sheet to text within selected documents.
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 STYLE="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 displays as:
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.
The second way to place style information in-line is to use a new element called SPAN. SPAN by itself doesn't mean anything; you use it to surround text to which you want to add style information. Here's how the SPAN element might be used:
<SPAN STYLE="margin-left: 1.0in"> This paragraph is 1.0 inches from the left margin.<SPAN>
This displays as:
This paragraph is 1.0 inches from the left margin.
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. For example:
<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, place this text before the BODY element:
<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 multiple 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">
Note You will need to make sure that the MIME type reported for "mystyles.css" is text/css.
The text formatting features supported by Internet Explorer 3.0 are described in this reference guide under the STYLE element.
![]() |
![]() |