Unit 1.2 HTML - Frames-1
Unit 1.2 HTML - Frames-1
Unit 1.2 HTML - Frames-1
HTML Frames are used to divide the web browser window into multiple sections
where each section can be loaded separately.
A frameset tag is the collection of frames in the browser window.
Creating Frames:
Instead of using body tag, use frameset tag in HTML to use frames in web browser.
But this Tag is deprecated in HTML 5.
The frameset tag is used to define how to divide the browser.
Each frame is indicated by frame tag and it basically defines which HTML document
shall open into the frame.
To define the horizontal frames use row attribute of frame tag in HTML document and
to define the vertical frames use col attribute of frame tag in HTML document.
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.
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
cols: The cols attribute is used to create vertical frames in web browser. This attribute
is basically used to define the no of columns and its size inside the frameset tag.
The size or width of the column is set in the frameset in the following ways:
•Use absolute value in pixel
Example:<frameset cols = "300, 400, 300">
•Use percentage value
Example:<frameset cols = "30%, 40%, 30%">
•Use wild card values:
Example:<frameset cols = "30%, *, 30%">
In the above example * will take the remaining percentage for creating vertical frame.
"Nesting" refers to embedding one object in another object of the same type.
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.
The interpretation of the rows and cols attributes changes slightly.
<FRAMESET ROWS="*,*">
<FRAMESET ...> the first row is itself a frameset </FRAMESET>
<FRAMESET ...> the second row is itself a frameset </FRAMESET>
</FRAMESET>
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.
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)
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
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”
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.
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.
<html>
<head></head>
<frameset rows="50%,*,2*" frameborder="no">
<frame src="one.htm" scrolling="no" bordercolor="cyan" name="try">
<frameset cols="50,*">
<frame src="a.htm" marginwidth="3" scrolling="no">
<frame src="a1.htm" height="500" width="200" noresize>
</frameset>
<frame src="a2.htm">
</frameset>
</html>
<html>
<head></head>
<BODY BGCOLOR="#FFFFAA" TEXT="black" LINK="blue"
VLINK="green" ALINK="red">
<p> this is just <a href="a.htm" target="_top"> For </a> testing.
</p>
<h1 style="color:blue;text-align:center">This is a header</h1>
<p style="color:green">This is a paragraph.</p>
</BODY>
</html>
There are additional attributes you can apply to the <frame> tag
that allow you to change border size and appearance. For
example:
you can remove borders from your frames to
free up more space for text and images
you can change the color of the frame border
so that it matches or complements the color
scheme for your Web site
Another way of modifying frame borders is to change their widths using the
border attribute.
The border attribute can be used only in the <frameset> tag, and not in
individual <frame> tags.
The syntax for the border attribute is: <frameset border=“value”>
value is the width of the frame borders in pixels
align="alignment" How the frame is aligned with the surrounding text (use "left" or "right" to flow text
This figure around the inline frame.)
shows some
of the other border="value" The size of the border around the frame, in pixels
attributes
frameborder="type" Specifies whether to display a border ("yes") or not ("no")
associated
with the classid="URL" The class identifier of the object
<iframe> tag.
height="value" The height and width of the frame, in pixels
width="value"
hspace="value" The horizontal and vertical space around the frame, in pixels
vspace="value"
scrolling="type" Specifies whether the frame can be scrolled ("yes") or not ("no")
Dr. Anupama Jha
src="URL" The location and filename of the page displayed in the frame
Creating a Floating Frame
<!DOCTYPE html>
<html>
<body>
<H2>Inline (Floating) Frames</H2>
<p>Microsoft Internet Explorer 3.0 introduced a feature called inline frames... </p><br>
<br><br>
<IFRAME NAME="float1" SRC="http://www.java2s.com" WIDTH=350 HEIGHT=200 ALIGN=LEFT>
There would be an floating frame here if your browser supported it.</IFRAME>
<br><br><br><br><br><br>
<P>This is a simple example of how floating frames are used.<BR>
Notice that in many ways the floating frame acts very similar to an inline image. <BR>
<br><br><br><br>
Floating frames act like embedded objects in many ways.</P>
<IFRAME SRC="pic1.jpg" WIDTH=200 HEIGHT=100 ALIGN=left HSPACE=12></IFRAME>
</BODY>
</HTML>