Navigation Bar | |||
---|---|---|---|
Main Table of Contents | Previous Chapter | Next Chapter |
172 Introduction To Style Sheets
You can use style sheets to define the formatting and layout of information on your Web pages. |
Style sheets are also known as Cascading Style Sheets (CSS). You can find more information about style sheets at the http://www.w3.org Web site. |
|
» Reasons For Using Style Sheets |
|
174 Set Up A Style Sheet
You can set up a style sheet that will define the formatting and layout for a single Web page or multiple Web pages. |
» For A Single Web Page |
|
Example: Set Up A Style Sheet |
<HTML> <Head> <Title> Web Page Design Techniques </Title> <Style> H1{text-align: center; font-style: italic} P{Color: White} </Style> </Head> <Body> |
When should I set up a style sheet for multiple Web pages? |
Setting up a style sheet for multiple Web pages allows you to give all of your Web pages a consistent appearance. When you make changes to the style sheet, all the Web pages that use the style sheet will display the changes. |
» For Multiple Web Pages |
|
Example: Style Sheet For Multiple Web Pages |
<HTML> <Head> <Title> Web Page Design Techniques </Title> <Link REL=stylesheet TYPE=text/css" HREF=mystyles.css> </Head> <Body> |
176 Create A Class
You can create a class to format only some of the elements on your Web page that use a specific tag. |
For example, you can create a class for elements that use tags such as H1 (H1 headings), P (paragraphs) or B (bold text). |
» Create A Class |
|
Example: Create A Class |
<HTML> <Head> <Title> Web Page Design Techniques </Title> <Style> P.important{font-style: italic; Color: White} </Style> </Head> <Body> |
The tags within the Body text look like: |
<P Class=important> Once upon a time there were... |
» Why Would I Create A Class? |
Creating a class gives you more control over the formatting and layout of information on your Web page. For example, you can create a class of important paragraphs (P.important) that will display slightly different formatting than regular paragraphs (P). |
The P.important paragraphs will display the formatting you define for regular (P) paragraphs as well as the formatting your define for P.important paragraphs. |
178 Hide A Style Sheet
You can hide a style sheet from older Web browsers that cannot understand style sheets. |
If you do not hide a style sheet from older Web browsers, the information for the style sheet may appear on your Web page. |
» Hide A Style Sheet |
|
Example: Hide A Style Sheet |
<HTML> <Head> <Title> Web Page Design Techniques </Title> <Style> <!-- H2{text-align: center; font-style: italic} P{Color: White} --> </Style> </Head> <Body> |
179 Change Text Alignment
» You can change the alignment of all the text on your Web page that uses a specific tag. |
|
Example: Change Text Alignment |
<HTML> <Head> <Title> Web Page Design Techniques </Title> <Style> H2{text-align: center} </Style> </Head> <Body> |
180 Bold Or Italicize Text
You can bold or italicize all the text on your Web page that uses a specific tag. |
Bolding or italicizing text is useful for emphasizing information on your Web page. |
» Bold Text |
|
» Italicize Text |
|
» Can I remove bold formatting from my Web page? |
You can remove bold formatting from all the text on your Web page that uses a specific tag. For example, you can remove bold formatting from text using a tag that automatically bolds text, such as B (bold) or H1 (H1 headings). |
|
Note: You can also remove italic formatting from all the text that uses a specific tag. Perform steps 1 and 2, except type font-style: normal in step 2. |
182 Change The Font
» Why should I specify more than one font? |
You should specify more than one font in case your first font choice is not available on a reader's computer. One of the fonts you specify should be a common font, such as Arial, to increase the probability that your Web page will display one of your font choices. |
» You can change the font of all the text on your Web page that uses a specific tag. |
|
Example: Change The Font |
<HTML> <Head> <Title> Web Page Design Techniques </Title> <Style> H2{font-family: "Brush Script MT", "Arial"} </Style> </Head> <Body> |
184 Change Font Size