Things That Have Changed -- Formatting Text For Appearance
Part II -- HTML Level 4 -- Pre-Defined Styles & Style Sheets Cascading Style Sheets are one of the most difficult aspects of HTML to learn, especially if you have no previous experience with things like page layout, desktop publishing, typesetting and other related activities. If you have desktop publishing or typesetting experience, learning CSS is just a matter of learning a new way to format your styles, but if you don't have such experience, it's a good idea to have at least a solid understanding of the basics of HTML before attempting to learn or use CSS. There are three basic ways of including CSS information in your HTML document. You can include the CSS information in the document itself, in a separate section of the document, or you can include the style information "inline", meaning actually within the individual tags, or the style sheet can be a separate document which is linked to other documents by way of a <LINK> reference. The way style information is included in this web site, for the most part, is by using this third method. A style sheet which is a separate document from all the other pages in the site is referenced in the Head section of the document. The element which references the style sheet for this web site looks like this: <LINK REL="stylesheet" HREF="style.css" TYPE="text/css">The style sheet to which this tag refers looks can be seen here. Here's how it works. You can define styles in a style sheet by defining styles (style declarations) for elements (selectors), by defining styles (declarations) for classes of tags or by defining declarations for element IDs. Here are some simple examples of these three different methods (these examples are formulated based on the assumption that the style sheet is referenced as a separate document with a <LINK> tag, as shown above, or is included in the <HEAD> element of the document. Examples of inline styles will come later): BODY {background: #FFFFFF;color: #000000} This CSS declares a style which is applied to the <BODY> selector, which means that all content which appears inside of <BODY>. . .</BODY> has those style attributes applied to it. This web page, the one you're looking at right now, and all the other pages in this site are examples of what this style looks like in practical use. The style defines a background color (white) and a text color (black). This style may or may not display correctly depending on which browser you're using to view these pages. The <BODY> style is only overridden by styles applied to elements which supercede the body element, such as paragraph, sample, span, division or preformatted elements. The following CSS information defines several classes of style for the paragraph element, which is another commonly used style in this web site: P.main {text-align: center;font-size: 18pt; font-weight: bold; font-family: Arial, Helvetica} P.sub {text-align: center; font-size: 14pt; font-weight: bold; font-family: Arial, Helvetica} P.body {text-indent: 0.25in; font-size: 10pt; font-family: Arial, Helvetica} P.cont {font-size: 10pt; font-family: Arial, Helvetica} These can be used with the <P> element, depending on what kind of format is desired. The main class style is centered, 18 point, bold Arial or Helvetica; a "main headline" style, the sub class style is a sub-head, the body class is a body text style with the first line indented, and the cont class is a body text style with no first line indent. Here are examples of how these classes can be used:
Styles can also be defined independently. Such styles can be used in conjunction with <SPAN> or <DIV> tags to create small sections of style, or they can be used as classes of tags, as shown above. The <SPAN> tag is used to create sections of a different style that are in line with other sections, the <SPAN> tag does not create a line break when it is closed. The <DIV> tag works the same way, except that when it is closed a line break also occurs. The following examples will illustrate the use of independently defined styles:
| ||||||||||||||||||
|