chapter 5 creating page templates

60
Chapter 5 Creating Page Templates

Upload: jasmine-whitaker

Post on 01-Jan-2016

58 views

Category:

Documents


2 download

DESCRIPTION

Chapter 5 Creating Page Templates. Chapter 5. Principles of Web Design. Objectives. Understand how tables can enhance the display of your content Use HTML table elements and attributes to customize page templates Learn how to take a page design from concept to HTML code - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 5 Creating Page Templates

Chapter 5

Creating Page Templates

Page 2: Chapter 5 Creating Page Templates

2

Principles of Web Design Chapter 5

Objectives

• Understand how tables can enhance the display of your content

• Use HTML table elements and attributes to customize page templates

• Learn how to take a page design from concept to HTML code

• Recognize and use basic page templates

Page 3: Chapter 5 Creating Page Templates

3

Principles of Web Design Chapter 5

Using Table Elements

• To build effective page templates, you must be familiar with the HTML table elements and attributes.

• The <TABLE> element contains the table information, which consists of table row elements <TR>, and individual table data cells <TD>. These are the three elements you will use most frequently when you are building tables.

Page 4: Chapter 5 Creating Page Templates

4

Principles of Web Design Chapter 5

Page 5: Chapter 5 Creating Page Templates

5

Principles of Web Design Chapter 5

A Basic Table

Figure 5-2 shows a basic table that uses these three table elements.

Page 6: Chapter 5 Creating Page Templates

6

Principles of Web Design Chapter 5

Basic Table Code<TABLE BORDER>

<TR><TD>Stock Number</TD><TD>Description</TD><TD>List Price</TD></TR>

<TR><TD>3476-AB</TD><TD>76mm Socket</TD><TD>45.00</TD></TR>

<TR><TD>3478-AB</TD><TD>78mm Socket</TD><TD>47.50</TD></TR>

<TR><TD>3480-AB</TD><TD>80mm Socket</TD><TD>50.00</TD></TR>

</TABLE>

Page 7: Chapter 5 Creating Page Templates

7

Principles of Web Design Chapter 5

Page 8: Chapter 5 Creating Page Templates

8

Principles of Web Design Chapter 5

Captions and Table Header• <CAPTION> lets you add a caption to the top

or bottom of the table. By default, captions display at the top of the table. You can use the ALIGN=BOTTOM attribute to align the caption at the bottom of the table.

• The <TH> tag lets you create a table header cell that presents the cell content as bold and centered.

Page 9: Chapter 5 Creating Page Templates

9

Principles of Web Design Chapter 5

Page 10: Chapter 5 Creating Page Templates

10

Principles of Web Design Chapter 5

Spanning Columns• Table attributes let you further define a

number of table characteristics. You can apply attributes at three levels of table structure: global, row-level, or cell-level.

Page 11: Chapter 5 Creating Page Templates

11

Principles of Web Design Chapter 5

Page 12: Chapter 5 Creating Page Templates

12

Principles of Web Design Chapter 5

Page 13: Chapter 5 Creating Page Templates

13

Principles of Web Design Chapter 5

Page 14: Chapter 5 Creating Page Templates

14

Principles of Web Design Chapter 5

Spanning Columns• The COLSPAN attribute lets you create cells

that span multiple columns of a table. Column spans cells always span to the right.

Page 15: Chapter 5 Creating Page Templates

15

Principles of Web Design Chapter 5

Page 16: Chapter 5 Creating Page Templates

16

Principles of Web Design Chapter 5

Spanning Rows• The ROWSPAN attribute lets you create

cells that span multiple rows of a table. Row spans always span down.

Page 17: Chapter 5 Creating Page Templates

17

Principles of Web Design Chapter 5

Page 18: Chapter 5 Creating Page Templates

18

Principles of Web Design Chapter 5

Relative or Absolute Widths• Set relative table widths as percentages in

the table WIDTH attribute. If you choose relative table widths, your tables will resize based on the size of the browser window.

• Set absolute table widths as pixel values in the table WIDTH attribute. Fixed tables remain constant regardless of the browser window size.

Page 19: Chapter 5 Creating Page Templates

19

Principles of Web Design Chapter 5

Page 20: Chapter 5 Creating Page Templates

20

Principles of Web Design Chapter 5

Page 21: Chapter 5 Creating Page Templates

21

Principles of Web Design Chapter 5

Calculating Table Widths• The most common width for page template

tables is between 580 and 600 pixels. This width supports the current lowest common denominator: 640 x 480 screen resolution.

• Internet Explorer displays tables slightly wider than Netscape, so you will find that 590 is an optimal fixed table width.

Page 22: Chapter 5 Creating Page Templates

22

Principles of Web Design Chapter 5

Page 23: Chapter 5 Creating Page Templates

23

Principles of Web Design Chapter 5

Default Table Spacing• Default spacing values are included in the

table even when you don’t specify values for the table’s border, cell-padding, or cell-spacing attributes.

• Depending on the browser, approximately two pixels are reserved for each of these values.

• You can remove the default spacing by explicitly stating a zero value for each attribute.

Page 24: Chapter 5 Creating Page Templates

24

Principles of Web Design Chapter 5

Page 25: Chapter 5 Creating Page Templates

25

Principles of Web Design Chapter 5

Page 26: Chapter 5 Creating Page Templates

26

Principles of Web Design Chapter 5

Page 27: Chapter 5 Creating Page Templates

27

Principles of Web Design Chapter 5

Table Pointers• Write easy-to-read code - You can simplify

your table creation and maintenance tasks by writing clean, commented code

• Remove extra spaces - Always remove any leading or trailing spaces in your table cell content

• Center tables - Centering a fixed table makes the table independent of resolution changes, because the table is always centered in the browser window

Page 28: Chapter 5 Creating Page Templates

28

Principles of Web Design Chapter 5

Table Pointers• Stack tables - Because of the way browsers

display tables, it’s best to build several smaller tables rather than one large one

• Nest tables - You can nest tables by placing an entire table within a table cell

Page 29: Chapter 5 Creating Page Templates

29

Principles of Web Design Chapter 5

Page 30: Chapter 5 Creating Page Templates

30

Principles of Web Design Chapter 5

Page 31: Chapter 5 Creating Page Templates

31

Principles of Web Design Chapter 5

Page 32: Chapter 5 Creating Page Templates

32

Principles of Web Design Chapter 5

Creating a Page Template• In this example you’ll see how to take a

design sketch for a Web page and build a template for the page layout.

• Figure 5-15 shows a sketch of the desired layout. This layout is designed for a base screen resolution of 640 x 480, so the table will be fixed at a width of 590 pixels.

Page 33: Chapter 5 Creating Page Templates

33

Principles of Web Design Chapter 5

Creating a Page Template• Notice that the basic structure of the table is

3 rows by 4 columns. Each column uses 25% of the total width of the template. Row spans and column spans break across the layout to provide visual interest.

Page 34: Chapter 5 Creating Page Templates

34

Principles of Web Design Chapter 5

Page 35: Chapter 5 Creating Page Templates

35

Principles of Web Design Chapter 5

Build the Basic Structure• Start by building the basic table structure,

including all the cells and rows of the table.• As you customize the table you can remove

extraneous cells as necessary. • The basic structure is a 3-row by 4-column

table.

Page 36: Chapter 5 Creating Page Templates

36

Principles of Web Design Chapter 5

Page 37: Chapter 5 Creating Page Templates

37

Principles of Web Design Chapter 5

Setting a Fixed Width• One of the design characteristics of the

template is a fixed width that is not dependent on the user’s browser size or screen resolution.

• To accomplish this, use a pixel value in the global WIDTH attribute. Figure 5-17 shows the result of setting the width to 590 pixels.

Page 38: Chapter 5 Creating Page Templates

38

Principles of Web Design Chapter 5

Page 39: Chapter 5 Creating Page Templates

39

Principles of Web Design Chapter 5

Creating the Page Banner• The page banner cell is R1C1. This cell

spans the four columns of the table using the COLSPAN attribute.

Page 40: Chapter 5 Creating Page Templates

40

Principles of Web Design Chapter 5

Page 41: Chapter 5 Creating Page Templates

41

Principles of Web Design Chapter 5

Creating the Feature Cell• The Feature cell in the layout is R2C2, and

spans two columns. This column span requires the removal of one cell in row two to make room for the span.

Page 42: Chapter 5 Creating Page Templates

42

Principles of Web Design Chapter 5

Page 43: Chapter 5 Creating Page Templates

43

Principles of Web Design Chapter 5

Creating the Link Columns• The New Link and Linked Ads columns in the

layout reside in cells R2C1 and R2C3 respectively. These cells span rows 2 and 3 of the table. The row spans require the removal of cells R3C1 and R3C4.

Page 44: Chapter 5 Creating Page Templates

44

Principles of Web Design Chapter 5

Page 45: Chapter 5 Creating Page Templates

45

Principles of Web Design Chapter 5

Creating the Page Banner• Column widths must be set in only one cell per

column.• It’s also best to set the column widths in only one

row of the table. • In the example template, no rows contain a cell

in each column of the table. The best way to set the widths for the columns is to add a fourth row to the table. This row acts as a width “control row.” These cells contain the WIDTH attributes and no content.

Page 46: Chapter 5 Creating Page Templates

46

Principles of Web Design Chapter 5

Page 47: Chapter 5 Creating Page Templates

47

Principles of Web Design Chapter 5

Testing the Template• To verify that your template works properly,

populate it with test content• Test the template in multiple browsers

Page 48: Chapter 5 Creating Page Templates

48

Principles of Web Design Chapter 5

Page 49: Chapter 5 Creating Page Templates

49

Principles of Web Design Chapter 5

Page 50: Chapter 5 Creating Page Templates

50

Principles of Web Design Chapter 5

Template Examples• The following templates cover a variety of

page layout needs • You may choose to stack different templates

on top of each other for more complex layouts

Page 51: Chapter 5 Creating Page Templates

51

Principles of Web Design Chapter 5

Page 52: Chapter 5 Creating Page Templates

52

Principles of Web Design Chapter 5

Page 53: Chapter 5 Creating Page Templates

53

Principles of Web Design Chapter 5

Page 54: Chapter 5 Creating Page Templates

54

Principles of Web Design Chapter 5

Page 55: Chapter 5 Creating Page Templates

55

Principles of Web Design Chapter 5

Page 56: Chapter 5 Creating Page Templates

56

Principles of Web Design Chapter 5

Page 57: Chapter 5 Creating Page Templates

57

Principles of Web Design Chapter 5

Page 58: Chapter 5 Creating Page Templates

58

Principles of Web Design Chapter 5

Summary• Plan your tables by sketching them out first. • Use fixed table widths if you want to

determine the size of your page rather than letting the browser determine the width.

• Use relative widths if you want to build tables that resize with the browser window, wrapping your content to fit.

Page 59: Chapter 5 Creating Page Templates

59

Principles of Web Design Chapter 5

Summary• Work on your pages with the table borders

turned on, which displays the cell boundaries. When you are finished with your layout you can turn the borders off.

• Size your tables based on the page size you want to create. Use 640 x 480 as your base screen resolution. In most cases you’ll set the width but not the height of your tables, allowing the content to flow down the page.

Page 60: Chapter 5 Creating Page Templates

60

Principles of Web Design Chapter 5

Summary• Test your work! Table settings, especially

cell widths and heights, can vary based on the user’s browser.