Unit 6: Hyperlinks, Lists, and CSS
| ! | Lesson Goal: Create styles for lists using the GoLive Style Editor and explore the CSS Box Model and how it is applied in GoLive. |
In this lesson, you will build upon the knowledge learned in the Lists lesson in order to style lists using the GoLive Style Editor, including the integration of images as list bullets. In addition, the CSS Box Model, used to place empty space around elements, will also be discussed.
|
This section addresses how to create styles to format numbered lists. You learned about creating internal and external styles in the Cascading Style Sheets 1 lesson. Let's do a brief review and then jump into creating a numbered list using styles. You should recall the first step in creating an internal style sheet in GoLive is to open the CSS Editor (see Figure 6.5-1). The CSS Editor button The next step involves creating an element style. These steps can be reviewed by going to the Creating Element Styles section of the CSS1 lesson. When you create an element style, it affects the formatting of every occurrence of that element within the page(s) linked to that style sheet. For example, if you create an |
Figure 6.5-1: CSS Editor |
Once the CSS Editor is open and the element for which a style will be created is identified, the next step is to define the new style in the CSS Style Inspector. We explored the CSS Style Inspector's Font and Text buttons previously; now let's see what options are available for lists.
|
The CSS Style Inspector List and Other Properties Tab (see Figure 6.5-2) appears when you click the List and Others button The Style drop-down box includes the following generic list options:
It also includes the following numbered list options:
The Position drop-down box offers three options:
|
Figure 6.5-2: CSS Style Inspector List and Other Properties Tab |
To create numbered list element styles, follow these steps:
Demonstration or Practice Activity
For this activity, you will create a numbered list element style.
ol li element.
Creating unnumbered list styles utilizes the same steps involved in creating numbered lists. The only differences are in the way you name the element style and in the chosen list item type.
To create unnumbered list element styles, follow these steps:
Demonstration or Practice Activity
For this activity, you will create an unnumbered element style.
ul li element.
|
You learned about nested lists in the List Levels section of the Lists lesson. Now it's time to learn how to save some time by creating styles for nested lists. Creating element styles for nested lists follows the same steps referred to previously for numbered and unnumbered lists; however, it requires close attention to the style names used. Notice the style names referred to in the CSS Editor in Figure 6.5-3:
Each successive list level requires either an additional |
Figure 6.5-3: CSS Editor |
Demonstration or Practice Activity
For this activity, you will create some nested element styles.
ol li set to Upper Roman
ol ol li set to Upper Alpha
ol ol ol li set to Lower Roman
NOTE: You may have to click the Document Window's Preview tab in order to see some of the changes; the list may not display as expected in the Layout Editor.
| It's time! |
Students should complete the following assignment from Student Guide 2:
|
|
The CSS Style Inspector List and Other Properties tab includes a checkbox for using an image as a list item marker (see Figure 6.5-4).
|
Figure 6.5-4: CSS Style Inspector List and Other Properties Tab |
Demonstration or Practice Activity
For this activity, you will create an unordered list style that uses images as bullets.
bullet_bluediamond.gif |
bullet_lavsquare.gif |
bullet_tealarrow.gif |
ul li set to use the teal arrowhead as a bullet
ul ul li set to use the lavender square as a bullet
ul ul ul li set to use the blue diamond as a bullet
NOTE: Remember to view the page in the Document Window's Preview tab in order to see the bullet images.
You know how to create element styles for lists; now it's time to learn how to create and apply class styles to lists. Creating and applying class styles to lists is similar to creating and applying class styles to text (see the Type-Related Styles in GoLive section of the CSS1 lesson). This will be a good review and give you an idea of other ways class styles can be used.
But first, let's address a more fundamental question: When should you use element styles versus class styles? Here are some general guidelines:
h1 and h2 headers or numbered lists or unnumbered lists to look a certain way most of the time, then set the default appearance for that element by creating an element class.
ul element. That way, you can call upon the class only in those cases when you wish to use it, but it won't become the default (as it would if you were to create an element style instead).
As you should recall, class styles don't get applied until you specify where the class is to be used within the HTML document (explained below).
To create class styles for use with lists, follow these steps:
Demonstration or Practice Activity
For this activity, you will create a class that will change the selected list item type to an image of your choice.
bullet_bluediamond.gif |
bullet_lavsquare.gif |
bullet_tealarrow.gif |
As you learned previously, applying classes requires the use of the CSS Palette. To apply class styles to list items, follow these steps (these steps assume that the class has already been created):
Demonstration or Practice Activity
For this activity, you will apply the new class styles to the lists.
| It's time! |
Students should complete the following assignments from Student Guide 2:
|
Although the CSS Box Model doesn't apply specifically or exclusively to lists, it is a very important aspect of cascading style sheets and needs to be discussed before we get further into the curriculum. A good example of how the box model can be applied on a Web page relates to setting a page's margin to accommodate an image on the side of the page. Let's learn a bit about the box model in general and then how to apply it in GoLive.
*** Begin section copyright © 2000-2003 ID 4 the Web ***
The CSS Box Model provides for a way to place empty space around elements. The box consists of space set aside for padding, borders, and margins. Some of the properties and associated values used by the CSS Box Model include:
The width property is used to define the horizontal width of the box. The values associated with the width property can be expressed in absolute terms (e.g., 100px) or in percentage terms (e.g., 20%). You may also use the preset values auto or inherit.
p {width: 50px}
The height property is used to define how tall the box is. The values associated with the height property can be expressed in absolute terms (e.g., 100px) or in percentage terms (e.g., 20%). You may also use the preset values auto or inherit.
p {height: 50px}
The margin property identifies the margins for the sides of the box. If you want all four margins to be equal, you can simply use the margin property as shown in Example 1 below. Otherwise, you can specify the four sides separately, using properties margin-top, margin-right, margin-bottom, and margin-left as shown in Example 2 below.
Example 1:
body {margin: 20px} Example 2:
body {margin-top: 20px;
margin-right: 25px;
margin-bottom: 30px;
margin-left: 35px;
}
The border property is used to surround an element with style, color, etc. The various border properties include border-width (e.g., thin, medium, or thick), border-style (e.g., none, dotted, dashed, solid, double, groove, ridge, inset, or outset) and border-color.
h1 {border-width: medium;
border-style: solid;
border-color: blue;
}
The padding property is used to identify the white-space between the content and the box border. If you want padding on all sides to be equal, you can simply use the padding property as shown in the example below. You can also specify the padding of each side separately, using properties padding-top, padding-right, padding-bottom, and padding-left.
h1 {padding: 20px}
|
To help you understand the relationships among In the three examples below, we use a paragraph as the content. In each case, the settings of |
Figure 6.5-5: CSS Box Model |
| Example | Browser Rendering |
|---|---|
p {border-width: thin; |
This paragraph has a thin-width, solid, black border, with no padding on the inside (between paragraph and border) and a 0-pixel margin on the outside (between border and whatever is outside the whole elementin this case, the border of the table cell holding the paragraph). |
p {border-width: medium; |
This paragraph has a medium-width, double, red border, with 10 pixels padding on the inside (between paragraph and border) and a 15-pixel margin on the outside (between border and whatever is outside the whole elementin this case, the border of the table cell holding the paragraph). |
p {border-width: thick; |
This paragraph has a thick-width, dashed, blue border, with 5 pixels padding on the inside (between paragraph and border) and a 30-pixel margin on the outside (between border and whatever is outside the whole elementin this case, the border of the table cell holding the paragraph). |
The W3C mentions several ways in which cascading style sheets benefit accessibility:
However, if you choose to use style sheets (and you are encouraged to do so to control layout and presentation), it is critical that your pages are still readable without style sheets. Always check your pages with style sheets turned off to make sure that they remain accessible to those with browsers that don't understand style sheets.
Additional Resources
If you'd like more information about cascading style sheets, see Web Design Group's Cascading Style Sheets page; it has multiple links to many interesting and helpful sites in both informational and tutorial formats. Of course, the ultimate resource is the W3C's CSS page.
*** End section copyright © 2000-2003 ID 4 the Web ***
Creating external style sheets was originally addressed in the Cascading Style Sheets 2 lesson. Let's do a brief review before we talk about utilizing the CSS Box Model in GoLive.
|
To create an external style sheet in GoLive, follow these steps:
|
Figure 6.5-6: External CSS Editor |
To link an external style sheet to an HTML document, follow these steps:
|
The CSS Box Model's
The unit of measurement can be selected and/or changed by selecting the pop-up arrow to the right of the desired box field. |
Figure 6.5-7: CSS Style Inspector Block Tab |
|
The CSS Box Model's
The unit of measurement (for column one) or the color (for column two) can be selected and/or changed by selecting the pop-up arrow to the right of the desired box field. |
Figure 6.5-8: CSS Style Inspector Border Tab |
Demonstration or Practice Activity
For this activity, you will create an external style sheet and link it to the index.html file of your "practice" site.
body element.
| It's time! |
Students should complete the following assignments from Student Guide 2:
|
Copyright © 2002-2003 Adobe Systems Incorporated, except those portions marked copyright © 2000-2003 ID 4 the Web. All rights reserved.