Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

HTML 4_01 Weekend Crash Course - G. Perry

.pdf
Скачиваний:
34
Добавлен:
24.05.2014
Размер:
6.32 Mб
Скачать

314

Sunday Morning

the top of the page easily by inserting these items in cells, adding new cells, and resizing cells that need to be resized. Without the table’s format, modifying one item in the header may negatively affect the formatting of the other items, and simple changes will become difficult.

Note

The added benefit of the table-based header is that the header’s colors and lines can span the user’s screen no matter what the screen width is.

The header shown in Figure 23-1 contains five rows and three columns. Not all the columns will be used on each row, but the three columns enable you to align all the data properly. For example, the first row contains only the hyperlink Home. On subsequent pages, Home will form a link back to this page. On this page, the link simply reloads the current page.

Note

Some Web masters utilize links such as this Home link on every page in a Web site, but they leave the link dead on the home page (meaning the text appears but no hyperlink is defined). Clicking a dead link keeps you on the same page, but clicking the link on subsequent pages returns the user to this home page. If you define the link, even on the home page, the page will reload, showing the user the purpose of the word. If the user clicks on the link but nothing happens, the user may not know to click the link on subsequent pages where the link is active. Therefore, consider activating all links, even same-page links.

The second row is a thin strip of white that separates the first and third rows. Table rows are rarely the same height except when they contain numerical data in a spreadsheet-like format.

The third row in the header table more obviously shows the three cells that make up the header. The cells will hold, from left to right, the family logo, the mailbox (which is a hyperlink to the family’s e-mail address in case anybody clicks the mailbox), and a gold-colored message that the Barkleys can easily change by altering the contents of the cell.

This tutorial’s CD-ROM contains all the graphic images used in the Barkley Web site.

Cross-Ref

Two more rows in Figure 23-1 contain two additional lines: one white and one golden. The golden text and lines work well with the green background of this Web

Session 23—The Web Site Home Page’s HTML

315

site. You won’t be able to distinguish the bottom two lines very well in this text’s figures, but if you follow along and create the HTML, you will see how well the colors work together.

To create the initial table, the Barkleys used the following code:

<table width=100% cellpadding=0 cellspacing=0 border=0 bgcolor=#009900>

The table will span 100 percent of the user’s screen without any padding or spacing between the cells or any border lines around the table. The table’s cell background colors will be green (#009900) unless overridden with a bgcolor= attribute set in one of the table’s <td> or <tr> tags.

Browsers determine a lot from a table by scanning the complete set of command tags from <table> to </table>. If the first row contains a single cell but the third row contains three cells, the entire table will be assumed to have three cells. Given that this page’s header will require three cells in the third row (the row with the logo), you might as well code the two extra cells on the first row of the table. Doing so makes it more obvious that the table contains three cells per row.

The following code defines the first row with the Home link:

<!-- First row is only a Home hotspot --> <tr>

<td height=21 width=179 align=left> <font face=Arial size=2>

<a href=”http://www.BarkleyFamilyPage.com/”> <b><i>Home</i></b></font></a>

</td>

<!-- Table needs two more cells defined --> <td width=169 height=21>

</td>

<td width=788 height=21> </td>

</tr>

The thin separating line between the first row and the third is specified in this code:

<tr> <!-- Blank Line as a thin row -->

<td colspan=3 bgcolor=white width=100% height=2 align=left> </td>

</tr>

Morning Sunday—V Part

23 Session

316

Sunday Morning

The width= attribute is huge to ensure that the line spans the entire width of the user’s screen.

The rest of the code that you’ll add defines the row with the logo and mailbox. This is the most detailed row in the table, as the next section explains.

Completing the Header Table

The rest of the header fills in the remaining three rows of the header table. The third row is the most complex because the row holds the logo, mailbox, and opening message. To the user’s eye, this row becomes the actual header; the rest of the rows are just decoration except for the lone Home hyperlink in the corner.

The logo falls into the first cell easily with this code:

<tr align=left> <!-- Logo -->

<td align=left width=”179” height=”24”>

<img src=”barkleys.gif” width=149 height=66 align=”absmiddle” alt=”Family Logo”>

</td>

As is virtually always true for graphics on your site, you should include the image’s width (width=) and height (height=) attributes so that the browser does not have to slow down to compute the dimensions. In addition, the alt= attribute ensures that something appears even when the user has turned off graphics in the browser. The alt= attribute also yields a pop-up ToolTip that reads Family Logo if the user rests the mouse pointer over the logo.

The next cell holds both a graphic image of the mailbox and a hyperlink to the family’s e-mail address. Although the Barkleys plan to add an e-mail link elsewhere, one here is nice and the GIF image performs a dual role: It acts as the hyperlink image and also conveys the idea “Here’s a Web page with Barkley news delivered to you.”

The following code defines the cell:

<td width=169 height=24> <p align=center>

     

<a href=”mailto:Barkleys@email.mn.net”>

<img border=0 src=”mailbox.gif” align=middle width=120 height=77 alt=”Mailbox”>

</a>

</td>

Session 23—The Web Site Home Page’s HTML

317

The four nonbreaking spaces add some room to the left of the mailbox. Although the mailbox could be fit there through other methods, such as justifying the mailbox to the right edge of the cells, the nonbreaking spaces enable you to place the picture more accurately. Although you won’t add hyperlinks to this page until Session 25, the Barkleys’ e-mail hyperlink (mailto:Barkleys@email.mn.net) is simple to add here before the mailbox graphic (src=”mailbox.jif”).

Finally, the remaining cell that holds the text, All the news that’s news for you, very simply closes out the row by placing the gold text on the green background. The nonbreaking spaces enable the Barkleys to adjust the spacing around the text to look somewhat centered.

Listing 23-4 shows the complete HTML code for the Web page as it now stands. The header is complete.

Listing 23-4

The completed header table code

<html>

 

 

<!------------------------------------

 

>

<!--

The Barkley Family Web site

-->

<!--

To relate news to family and

-->

<!--

friends around the world.

-->

<!--

Created: June 4, 2003

-->

<!--

Last modified: August 15, 2003

-->

<!--

Write wBarkley@ourweb.net if

-->

<!--

you have questions.

-->

<!------------------------------------

 

>

<!----------------------------

>

 

<!--

The header begins here -->

 

<!----------------------------

>

 

<head>

<title>The Barkley Family Web Page</title>

<table width=100% cellpadding=0 cellspacing=0 border=0 bgcolor=#009900>

Morning Sunday—V Part

23 Session

Continued

318

Sunday Morning

Listing 23-4 Continued

<!-- First row only contains a Home link --> <tr>

<td height=21 width=179 align=left> <font face=Arial size=2>

<a href=”http://www.BarkleyFamilyPage.com/”> <b><i>Home</i></b></font></a>

</td>

<!-- Table needs two more cells defined --> <td width=169 height=21>

</td>

<td width=788 height=21> </td>

</tr>

<tr> <!-- Blank Line as a thin row -->

<td colspan=3 bgcolor=white width=100% height=2 align=left> </td>

</tr>

<tr align=left> <!-- Logo -->

<td align=left width=”179” height=”24”>

<img src=”barkleys.gif” width=149 height=66 align=”absmiddle”

alt=”Family Logo” border=0> </td>

<td width=169 height=24> <p align=center>

     

<a href=”mailto:Barkleys@email.mn.net”>

<img border=0 src=”mailbox.gif” align=middle width=120 height=77>

</a>

</td>

<td height=24>

<font face=Arial size=6 color=#CC9900>     All the news<br>

Session 23—The Web Site Home Page’s HTML

319

 that’s new for you</font>

 

</td>

 

 

 

<tr>

<!--

Blank Line as a thin row --

>

<td colspan=3 bgcolor=white width=100% height=2 align=left>

</td>

 

 

 

</tr>

 

 

 

<tr>

<!--

Golden Line as a thin row --

>

<td colspan=3 bgcolor=#CC9900 width=100% height=2 align=left>

</td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</head>

 

 

 

<!--------------------------

 

>

 

<!-- The body begins here -->

 

<!--------------------------

 

>

 

<body bgcolor=”#009900”>

 

<!--------------------------

>

<!-- Any footer goes here --

>

<!--------------------------

>

</body>

 

</html>

 

The second table that will appear on the page will be the body of the page that holds the navigation bar, and home page content comes next. You’ll follow the next session and create the Barkley family’s home page’s body from this remaining table.

REVIEW

Morning Sunday—V Part

23 Session

An HTML template helps you get your Web page started.

Documentation makes your HTML code clearer and easier to maintain.

320

Sunday Morning

The header is often a table that spans the user’s entire screen width.

Contact information in a header hyperlink enables users to contact you about your site.

QUIZ YOURSELF

1.What can happen if you place undivided comments throughout the sections of an HTML Web page? (See “The Initial HTML Template.”)

2.Why should you not always include your address and phone number in the opening comment section of your Web page? (See “Document the Code.”)

3.What width advantage can a table provide for the header? (See “Starting the Header Table.”)

4.What is an advantage to activating same-page hyperlinks? (See “The Top Table.”)

5.Why do you often see nonbreaking spaces scattered throughout HTML code? (See “Completing the Header Table.”)

S E S S I O N

24

The Web Site Home Page’s

Text and Graphics

Session Checklist

Understand the table that creates the Barkleys’ home page contents

Create the Barkleys’ navigation bar from a table

Remember to create simple Web home pages

Create the Barkleys’ thumbnail images and text from a table

In this session, you continue building the Barkley family home page that you began in the previous sessions. The page is coming along nicely. Here, you’ll put the header that is now complete at the top of all the site’s Web pages, and

you’ll add some new elements as well. The rest of the home page includes a single table that holds the navigation bar and the primary page’s content. If you are following along, load the HTML code that you created from the previous session and begin.

322

Sunday Morning

The Home Page’s Bottom Table

As noted in the previous session, the Barkley home page consists of two tables: one for the header and the other for the navigation bar and the contents. The graphics program mark-up lines, repeated in Figure 24-1, show the three cells of the lower table and how the cells hold and help place and align their contents. The three cells contain the navigation bar, thumbnail images, and text.

Figure 24-1

The table’s cells enable you to manage a Web page more easily.

Although the Barkleys chose white on green letters for the heading and the navigation menu down the left side of the page, they wisely decided on a white background for the central content’s table background color. All the Web site’s content appears in this large, central area. Nothing works better than a white background. Other colors will make your users hesitate somewhat because the eye does not adjust well to many text and background color combinations. Some color combinations can slow the reading of a Web page by 10 percent or more. To be safe, use a white background.

Session 24—The Web Site Home Page’s Text and Graphics

323

 

 

Make sure that your table background colors match those of the

 

 

Web page’s background on which the tables lie or that the tables

Note

are as wide as the entire Web page. Otherwise, the browser will

leave a border around the outside of your tables. For example,

 

 

Figure 24-2 shows what happens when the Web page’s back-

 

 

 

 

ground color is white but the heading is green. Because the

 

 

 

 

header’s tables do not take the width of the Web page, the page’s

 

 

white background creates a white border around the heading. By

 

 

specifying a green page background, the heading and other

 

 

 

 

tables are not outlined.

 

 

 

 

 

 

 

 

 

 

 

 

Figure 24-2

Don’t outline your header table by specifying a different body background color.

The following statement defines the table that comprises the bottom of the home page:

Morning Sunday—V Part

24 Session

<table border=0 width=2000 height=3 cellspacing=0 cellpadding=0>