MUBEEN ASLAM
HTML Frames
OBJECTIVES
 Create/control appearance & placement
of frames
 Control the behavior of hyperlinks on
pages with frames
 Use reserved target names to specify a
target for a hypertext link
 Browsers that support frames and by
those that do not
 Create and implement floating frames
ADVANTAGES TO USING FRAMES
 flexibility in design
 information in different Web pages
 remove redundancy.
 site easier to manage.
 update only a few files rather than the whole.
 Web designers create both framed and non-
framed versions for a Web site and give
users the option of which one to use.
DISADVANTAGES TO USING FRAMES
 The browser has to load multiple HTML files
 increasing wait time
 Some older browsers cannot display frames.
 Some users do not like using frames.
 Some web authors feel that frames are too
constricting.
 Frames can use up valuable screen space.
 The source code is hidden.
CREATING A FRAME LAYOUT
 The <frameset> tag is used to store the definitions of the various frames
in the file. These definitions will typically:
 include the size and location of the frame
 include the Web pages the frames display
 The <frameset> code does not include an opening and closing <body>
tag.
 the reason for this is that this HTML file displays
the contents of other Web pages; technically, it is
not a Web page
SPECIFYING FRAME SIZE AND ORIENTATION
 For frame layout
 use rows and cols attributes of <frameset>
 frameset is defined by rows or columns, but
not both usually.
 Must choose to layout frames in either rows or
columns.
 Both rows and columns can be used together
but not recommended because of the increase
of complexity of the code. Not easy to manage.
THE FRAME SYNTAX
 The syntax for creating a row or column frame
layout is:
 <frameset rows=“row height 1,
row height 2, row height 3, . . .”>
 row height is the height of each row
or
 <frameset cols=“column width 1,
column width 2, column width 3, . . .”>
 column width is the width of each column
ROW AND COLUMN SIZES
 Row and column sizes can be specified in
three ways:
 in pixels
 as a percentage of the total size of the frameset
 by an asterisk (*)
DEFINING ROWS AND COLUMNS USING (*)
 Tells the browser to allocate any unclaimed space
in the frameset to the particular row or column.
 <frameset rows=“160,*”>
creates two rows of frames.
 Specify at least 1 of the rows or cols of
<frameset> with (*) to ensure that the frames fill
up the screen.
 You can use multiple asterisks.
 The browser divides the remaining display space
equally among the frames with the asterisks.
 <frameset rows=“*,*,*”>
creates three rows of frames with equal heights.
SPECIFYING A FRAME SOURCE
 To specify a source for a frame, use the
<frame> tag with the syntax:
<frame src=“URL”>
 The URL is the filename and location of the
page that you want to load.
 You must insert the <frame> tag between
the opening and closing <frameset> tags.
NESTING <FRAMESET> TAG
 Remember that a frameset is defined by
rows or columns, but not both.
 To create frames using both rows and
columns, one frameset must be nested
inside another(Recommended-standard)
 The interpretation of the rows and cols
attributes changes slightly.
CONTROLLING THE APPEARANCE OF YOUR
FRAMES
 You can control three attributes of a frame:
 scroll bars
 the size of the margin between the source
document and the frame border
 whether or not the user is allowed to change the
size of the frame
CONTROLLING THE APPEARANCE OF SCROLL
BARS
 By default, scroll bars are displayed when
the content of the source page cannot fit
within the frame.
 You can override the default setting using the
scrolling attribute.
 The scrolling syntax is: <frame src=“URL”
scrolling=“scrolling”>
 scrolling can either be “yes” (to always display scroll
bars) or “no” (to never display scroll bars) or “auto”
REMOVING THE SCROLL BARS FROM THE LOGO
FRAME
If the complete text cannot be
displayed after removing the
scroll bars from a frame, you
will need to modify the frame
margin.
<FRAME NAME="left frame“ SRC="left frame.html" scrolling="no"
marginwidth="50“ marginheight="40“ bordercolor="yellow">
set the scrolling
attribute to “no” to
remove the scroll
bars
CONTROLLING FRAME MARGINS
 The following should be consider for frame
margins:
 the browser determines the amount of space between the
content of the page and the frame border
 occasionally, the browser sets the margin between the border
and the content too large
 the margin should be big enough to keep the source’s text or
images from running into the frame’s borders
 the margin should not take up too much space, because you
typically want to display as much of the source as possible
SPECIFYING MARGINS SYNTAX
 The syntax for specifying margins for a
frame is: <frame src=“URL”
marginheight=“value”
marginwidth=“value”>
 marginheight is the amount of space, in pixels, above
and below the content of the page in the frame
 marginwidth is the amount of space to the left and right
of the page
 If you specify only one, the browser
assumes that you want to use the same
value for both.
CONTROLLING FRAME RESIZING
 By default, users can resize frame borders
 Web designers can freeze, or lock, frames,
so that users cannot resize them.
 The syntax for controlling frame resizing is:
<frame src=“URL” noresize>
 The noresize attribute
WORKING WITH FRAMES AND HYPERTEXT
LINKS
 By default, clicking a hyperlink within a frame
opens the linked file inside the same frame.
 You can display hyperlinks in many ways:
 in a different frame
 in a new window
 in the entire window
 When you want to control the behavior of
hyperlinks in a framed page, there are two
required steps:
 give each frame on the page a Name
 point each hyperlink to one of the named frames
ASSIGNING A NAME TO A FRAME
 To assign a name to a frame, add the name
attribute to the frame tag.
 The syntax for this attribute is:
<frame src=“URL” name=“frame_name”>
 frame_name is any single word you assign to the frame
 case is important in assigning names: “information” is
considered a different name than “INFORMATION”
ASSIGNING A NAME TO EACH FRAME
Once the frames are
named, the next task is to
specify the target frame for
each hyperlink.
<FRAME NAME="leftframe" SRC="leftframe.html" scrolling="no"
marginwidth="50" marginheight="40" bordercolor="yellow">
the frame name
<FRAME NAME="mainframe" SRC="right frame.html" scrolling="auto"
marginwidth="400" marginheight="100" bordercolor="green" >
SPECIFYING A LINK TARGET
 You can use the target attribute to open a page in
a specific frame.
 The syntax for this is:
<a href=“URL” target=“frame_name”>
 frame_name is the name you’ve assigned to a frame on your
Web page
 When a page contains dozens of hyperlinks that
should all open in the same frame, HTML
provides a way to specify a target frame for all the
hyperlinks within a single page.
hello <br>
BSCS 6<br>
Its the SIDE Frame <br>
<a href="banner.html" target="mainframe">Banner In Main Frame</a>
leftframe.html
<a href="welcomepage.html" target="mainframe" >WELCOME</a>
leftframe.html
USING RESERVED TARGET NAMES
 Reserved target names are special names that can be used in
place of a frame name as the target.
 They are useful in situations:
 where the name of the frame is unavailable
 when you want the page to appear in a new window
 when you want the page to replace the current browser window
 All reserved target names begin with the underscore character
( _ ) to distinguish them from other target names.
 Reserved target names are case-sensitive, they must be entered
in lowercase.
RESERVED TARGET NAMES
This figure describes the reserved target names.

Html Frames

  • 1.
  • 2.
    OBJECTIVES  Create/control appearance& placement of frames  Control the behavior of hyperlinks on pages with frames  Use reserved target names to specify a target for a hypertext link  Browsers that support frames and by those that do not  Create and implement floating frames
  • 3.
    ADVANTAGES TO USINGFRAMES  flexibility in design  information in different Web pages  remove redundancy.  site easier to manage.  update only a few files rather than the whole.  Web designers create both framed and non- framed versions for a Web site and give users the option of which one to use.
  • 4.
    DISADVANTAGES TO USINGFRAMES  The browser has to load multiple HTML files  increasing wait time  Some older browsers cannot display frames.  Some users do not like using frames.  Some web authors feel that frames are too constricting.  Frames can use up valuable screen space.  The source code is hidden.
  • 5.
    CREATING A FRAMELAYOUT  The <frameset> tag is used to store the definitions of the various frames in the file. These definitions will typically:  include the size and location of the frame  include the Web pages the frames display  The <frameset> code does not include an opening and closing <body> tag.  the reason for this is that this HTML file displays the contents of other Web pages; technically, it is not a Web page
  • 6.
    SPECIFYING FRAME SIZEAND ORIENTATION  For frame layout  use rows and cols attributes of <frameset>  frameset is defined by rows or columns, but not both usually.  Must choose to layout frames in either rows or columns.  Both rows and columns can be used together but not recommended because of the increase of complexity of the code. Not easy to manage.
  • 7.
    THE FRAME SYNTAX The syntax for creating a row or column frame layout is:  <frameset rows=“row height 1, row height 2, row height 3, . . .”>  row height is the height of each row or  <frameset cols=“column width 1, column width 2, column width 3, . . .”>  column width is the width of each column
  • 8.
    ROW AND COLUMNSIZES  Row and column sizes can be specified in three ways:  in pixels  as a percentage of the total size of the frameset  by an asterisk (*)
  • 9.
    DEFINING ROWS ANDCOLUMNS USING (*)  Tells the browser to allocate any unclaimed space in the frameset to the particular row or column.  <frameset rows=“160,*”> creates two rows of frames.  Specify at least 1 of the rows or cols of <frameset> with (*) to ensure that the frames fill up the screen.  You can use multiple asterisks.  The browser divides the remaining display space equally among the frames with the asterisks.  <frameset rows=“*,*,*”> creates three rows of frames with equal heights.
  • 10.
    SPECIFYING A FRAMESOURCE  To specify a source for a frame, use the <frame> tag with the syntax: <frame src=“URL”>  The URL is the filename and location of the page that you want to load.  You must insert the <frame> tag between the opening and closing <frameset> tags.
  • 11.
    NESTING <FRAMESET> TAG Remember that a frameset is defined by rows or columns, but not both.  To create frames using both rows and columns, one frameset must be nested inside another(Recommended-standard)  The interpretation of the rows and cols attributes changes slightly.
  • 12.
    CONTROLLING THE APPEARANCEOF YOUR FRAMES  You can control three attributes of a frame:  scroll bars  the size of the margin between the source document and the frame border  whether or not the user is allowed to change the size of the frame
  • 13.
    CONTROLLING THE APPEARANCEOF SCROLL BARS  By default, scroll bars are displayed when the content of the source page cannot fit within the frame.  You can override the default setting using the scrolling attribute.  The scrolling syntax is: <frame src=“URL” scrolling=“scrolling”>  scrolling can either be “yes” (to always display scroll bars) or “no” (to never display scroll bars) or “auto”
  • 14.
    REMOVING THE SCROLLBARS FROM THE LOGO FRAME If the complete text cannot be displayed after removing the scroll bars from a frame, you will need to modify the frame margin. <FRAME NAME="left frame“ SRC="left frame.html" scrolling="no" marginwidth="50“ marginheight="40“ bordercolor="yellow"> set the scrolling attribute to “no” to remove the scroll bars
  • 15.
    CONTROLLING FRAME MARGINS The following should be consider for frame margins:  the browser determines the amount of space between the content of the page and the frame border  occasionally, the browser sets the margin between the border and the content too large  the margin should be big enough to keep the source’s text or images from running into the frame’s borders  the margin should not take up too much space, because you typically want to display as much of the source as possible
  • 16.
    SPECIFYING MARGINS SYNTAX The syntax for specifying margins for a frame is: <frame src=“URL” marginheight=“value” marginwidth=“value”>  marginheight is the amount of space, in pixels, above and below the content of the page in the frame  marginwidth is the amount of space to the left and right of the page  If you specify only one, the browser assumes that you want to use the same value for both.
  • 17.
    CONTROLLING FRAME RESIZING By default, users can resize frame borders  Web designers can freeze, or lock, frames, so that users cannot resize them.  The syntax for controlling frame resizing is: <frame src=“URL” noresize>  The noresize attribute
  • 18.
    WORKING WITH FRAMESAND HYPERTEXT LINKS  By default, clicking a hyperlink within a frame opens the linked file inside the same frame.  You can display hyperlinks in many ways:  in a different frame  in a new window  in the entire window  When you want to control the behavior of hyperlinks in a framed page, there are two required steps:  give each frame on the page a Name  point each hyperlink to one of the named frames
  • 19.
    ASSIGNING A NAMETO A FRAME  To assign a name to a frame, add the name attribute to the frame tag.  The syntax for this attribute is: <frame src=“URL” name=“frame_name”>  frame_name is any single word you assign to the frame  case is important in assigning names: “information” is considered a different name than “INFORMATION”
  • 20.
    ASSIGNING A NAMETO EACH FRAME Once the frames are named, the next task is to specify the target frame for each hyperlink. <FRAME NAME="leftframe" SRC="leftframe.html" scrolling="no" marginwidth="50" marginheight="40" bordercolor="yellow"> the frame name <FRAME NAME="mainframe" SRC="right frame.html" scrolling="auto" marginwidth="400" marginheight="100" bordercolor="green" >
  • 21.
    SPECIFYING A LINKTARGET  You can use the target attribute to open a page in a specific frame.  The syntax for this is: <a href=“URL” target=“frame_name”>  frame_name is the name you’ve assigned to a frame on your Web page  When a page contains dozens of hyperlinks that should all open in the same frame, HTML provides a way to specify a target frame for all the hyperlinks within a single page.
  • 22.
    hello <br> BSCS 6<br> Itsthe SIDE Frame <br> <a href="banner.html" target="mainframe">Banner In Main Frame</a> leftframe.html
  • 23.
  • 24.
    USING RESERVED TARGETNAMES  Reserved target names are special names that can be used in place of a frame name as the target.  They are useful in situations:  where the name of the frame is unavailable  when you want the page to appear in a new window  when you want the page to replace the current browser window  All reserved target names begin with the underscore character ( _ ) to distinguish them from other target names.  Reserved target names are case-sensitive, they must be entered in lowercase.
  • 25.
    RESERVED TARGET NAMES Thisfigure describes the reserved target names.