Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and...

48
Chapter 8 HTML Frames

Transcript of Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and...

Page 1: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

Chapter 8

HTML Frames

Page 2: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

2

Principles of Web Design Chapter 8

Objectives

• Understand the benefits and drawbacks of frames

• Understand and use frames syntax• Customize frame characteristics including

scroll bars, borders, and margins• Understand and use frame targeting and

special targeting names• Design content to properly fit framesets

Page 3: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

3

Principles of Web Design Chapter 8

Objectives

• Design framesets that accommodate different screen resolutions

• Design content to properly fit framesets• Design framesets that accommodate different

screen resolutions

Page 4: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

4

Principles of Web Design Chapter 8

Understanding Frames

• Frames allow you to divide the browser window into independent windows, each displaying a separate HTML document

Page 5: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

5

Principles of Web Design Chapter 8

Page 6: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

6

Principles of Web Design Chapter 8

Frame Benefits• Frames allow users to scroll independently in

one frame without affecting the contents of an adjoining frame

• Frames are an ideal way to present large collections of information that are hard to navigate using traditional single-page browser display

Page 7: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

7

Principles of Web Design Chapter 8

Page 8: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

8

Principles of Web Design Chapter 8

Frame Drawbacks• Inaccurate bookmarking• Download overhead• Visual and navigation confusion• Poor indexing with search engines

Page 9: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

9

Principles of Web Design Chapter 8

Frame Syntax

<FRAMESET ROWS=”50%,50%”>

<FRAME SRC=”top.htm”>

<FRAME SRC=”bottom.htm”>

</FRAMESET>

Two-row frame set:

Page 10: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

10

Principles of Web Design Chapter 8

Page 11: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

11

Principles of Web Design Chapter 8

Frame Syntax

<FRAMESET COLS=”150,*”>

<FRAME SRC=”left.htm”>

<FRAME SRC=”right.htm”>

</FRAMESET>

Two-column frame set:

Page 12: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

12

Principles of Web Design Chapter 8

Page 13: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

13

Principles of Web Design Chapter 8

Frame Syntax

<FRAMESET ROWS="40,*">

<FRAME SRC="topnav.htm"> <FRAMESET COLS="20%,80%"> <FRAME SRC="left.htm">

<FRAME SRC="right.htm">

</FRAMESET>

</FRAMESET>

Nested frame set:

Page 14: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

14

Principles of Web Design Chapter 8

Page 15: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

15

Principles of Web Design Chapter 8

Restricting Resizing

• By default, the user has the option of resizing your frames by clicking and dragging the frame border

• In most situations you probably want to restrict resizing, so that the user sees the frameset the way you intended

• To restrict resizing, add the NORESIZE attribute to the <SRC> elements in your frameset

Page 16: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

16

Principles of Web Design Chapter 8

Page 17: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

17

Principles of Web Design Chapter 8

Controlling Scroll Bars

• By default, scroll bars in frames are set to appear automatically when needed if the content is not accessible within the frame window

• Remove the scroll bar by adding the SCROLLING=NO attribute to the <SRC> element

Page 18: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

18

Principles of Web Design Chapter 8

Page 19: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

19

Principles of Web Design Chapter 8

Page 20: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

20

Principles of Web Design Chapter 8

Controlling Frame Borders• As with tables, you can choose not to display

frame borders, or to remove the default border spacing between frames entirely

• This technique lets you create seamless frames with no visible dividing line (unless a scroll bar pops up)

• To remove frame borders, add FRAMEBORDER=NO FRAMESPACING=0 BORDER=0 to the <FRAMESET> tag

Page 21: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

21

Principles of Web Design Chapter 8

Page 22: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

22

Principles of Web Design Chapter 8

Removing Frame Margins

• Two frame attributes let you control the pixel width of both the vertical and horizontal margins in a frame

• MARGINWIDTH lets you control the left and right margin, while MARGINHEIGHT affects the top and bottom margins

• Setting these attributes to 0 lets you remove the margins entirely, allowing your content to touch the sides of the frame

Page 23: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

23

Principles of Web Design Chapter 8

Page 24: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

24

Principles of Web Design Chapter 8

Frame Targeting

• By default, a link loads into the same frame from which it was selected.

• You can change this default behavior and target the destination of a link to another frame in the frameset

Page 25: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

25

Principles of Web Design Chapter 8

Page 26: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

26

Principles of Web Design Chapter 8

Frame Targeting

To target from one frame to another, you must perform two tasks:

1. Name your frames using the NAME attribute in the FRAME element

2. Target links to display their content in the named frame

Page 27: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

27

Principles of Web Design Chapter 8

Naming Frames• To name a frame, add the NAME attribute to the <FRAME>

element • You do not have to name all of the frames within a frameset,

only the frames you want to target

<FRAME SRC="article1.htm" NAME="content">

Page 28: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

28

Principles of Web Design Chapter 8

Targeting Named Frames• To target the named frame you must edit the HTML document that contains

the <A> elements and provide TARGET attributes that tell the browser which frame displays the content

• You can use the TARGET attribute in either the <BASE> or <A> elements

Page 29: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

29

Principles of Web Design Chapter 8

Targeting Named Frames• Adding the <BASE> element lets you set the

default target frame for all of the links in the document

• You can override a default base target by using the TARGET attribute in the <A> element

<A HREF="article1.htm" TARGET=”frame2”>Article 1</A>

<BASE TARGET="main">

Page 30: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

30

Principles of Web Design Chapter 8

Page 31: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

31

Principles of Web Design Chapter 8

Using Special Target Names

• There are four special target names that you can use with the TARGET attribute in either the <BASE> or <A> elements

• Notice that all of these special names begin with an underscore. Any other target name that begins with an underscore will be ignored by the browser

Page 32: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

32

Principles of Web Design Chapter 8

Page 33: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

33

Principles of Web Design Chapter 8

Page 34: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

34

Principles of Web Design Chapter 8

Using _blank

• The _blank special target name lets you load the linked content into a new instance of Netscape

• Notice that the Back button is not available in the new browser window because this is the first page in the new window. Not being able to use Back can be disorienting to users who rely on it for navigation

Page 35: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

35

Principles of Web Design Chapter 8

Page 36: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

36

Principles of Web Design Chapter 8

Using _top

• Using _top as a special target name displays the linked content in a non-framed window using the same instance of the browser

• The Back button is available if the user wants to return to the previous page. Since the browser maintains only one open window, there is no additional memory overhead or confusion for the user

Page 37: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

37

Principles of Web Design Chapter 8

Page 38: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

38

Principles of Web Design Chapter 8

Frames and Screen Resolution

• Frame scrollbars and borders add to the screen space requirements of frames

• Small differences between the way browsers display frames can greatly affect their look

Page 39: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

39

Principles of Web Design Chapter 8

Page 40: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

40

Principles of Web Design Chapter 8

Page 41: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

41

Principles of Web Design Chapter 8

Designing Effective Frames• Build your pages to fit within the frames in which

they will display, and accommodate different screen resolutions that can affect the size of the frame within the frameset

• Decide whether you will use fixed or relative framesets

• You can also choose to mix these two measurement types within a single frameset, which can be the best way to handle multiple screen resolutions

Page 42: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

42

Principles of Web Design Chapter 8

Page 43: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

43

Principles of Web Design Chapter 8

Page 44: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

44

Principles of Web Design Chapter 8

Page 45: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

45

Principles of Web Design Chapter 8

Page 46: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

46

Principles of Web Design Chapter 8

Summary• Use frames judiciously. Make sure that your

content demands or benefits from the use of frames.

• Build simple framesets with no more than two or three frames.

• Be aware of the limitations of frames, including possibly increased download times and potential navigation confusion.

Page 47: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

47

Principles of Web Design Chapter 8

Summary• Because frameset documents contain no

content of their own, they are not the best choice for the top-level page of your Web site. Consider using a standard HTML page for the top-level of the site, and then link the user to your framed content.

• Use the <NOFRAMES> element to contain alternate information about your Web site for users with browsers that cannot display frames.

Page 48: Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.

48

Principles of Web Design Chapter 8

Summary• Use the special target names to solve unique

design problems, favoring _top over _blank whenever possible.

• Build your framesets using a combination of fixed and variable frame widths to accommodate different screen resolutions.

• Test your work! Different browsers and screen resolutions affect the look of your framesets.