Lecture-10 : FRAMES IN HTML

HTML frames are used to divide your browser window into multiple sections. In each frame we can open or load a separate HTML document. Two or more HTML documents can be seen in the browser simultaneously. A collection of frames in the browser window is known as a frameset.

To have frames in window we use frames. To do this we use the <frameset> tag which indicates the browser that the web page window has frame and corresponding tag to close the frame </frameset>. We can divide a window into multiple into multiple frames. This can be done by <frameset> …..... </frameset> tag. We can divide it into rows and columns by using framesetattribute such as rows and cols.

We can make hyperlinks in between the HTML documents existing on different frames. The main benefit of this approach is in the navigation. Users can view the information in one frame while keeping the other frame open for reference.

Advantages of Using Frames
• One of the most beneficial feature of frames is it lets the user to have multiple pages in the same browser.
• Using frames we can keep one part of the page static while changing the other parts of the page.
• If we create a top frame we can use it as a header i.e, as that page is static it acts like an include page.
• Frames can be used to reduce server load, as there is no need to reload all the pages when ever a new page is visited .

Disadvantages of Using Frames
• One of the main disadvantage of frames is search engines will not deal with them properly. i.e, search engines (including most popular ones) will not index pages containing frames as its hard for them to search for a specific content and move backwards to check to which frameset each page belongs to and retrieve all the pages in the frameset.
• Its hard to navigate through pages in frames when we have more than two or three frames.
• Its difficult to print the content of all frames when compared to a normal web page.
• Some browsers doesn't support frames, so we need to place the content separately for the people who doesn't have frames using <noframes> ... </noframes>.
• We cannot bookmark individual pages using browser's Favorites Menu.

Attributes of Frame tag:-

src :- This attribute is used to give the file name that should be loaded in the frame. Its value can be any URL. For example, src="top.html" will load an HTML file available in html directory.

Frameborder :- This attribute specifies that the border of the frame is shown or not; it overrides the value given in the frameborder attribute on the <frameset> tag if one is given, and this can take values either 1 (yes) or 0 (no).

Target Element :- The hyperlink frame contains this hyperlink code contains an anchor tag as example, <a href=”index.html” target=”frame1”> target is an anchor element and index.html file will be loaded in the frame whose name is “frame1”. Target can be setto many values such as

_self :- it displays the page in the same browser window.

_blank :- It displays the page in a new blank browser window.

_parent :- it change the frameset which encapsulate the current frame.

_top :- It enables the full browser window to display the requested page.

Scrolling :- This attribute specifies to show the scrollbars or not that appear on the frame. This takes values either "yes", "no" or "auto". For example scrolling="no" means it should not have scroll bars.

Example of frame tag :-

<title>Frame Collection</title>
<frameset rows = "40%, *">
<frame src="top.html" name="upper" >
<frame src="" name= " lower" >

<body bgcolor="#99CCFF">
<h1 align="center">top.html</h1>


Frameset Mixed

<!DOCTYPE html>

<frameset rows="50%,50%">
<frame src="top.html">
<frameset cols="25%,75%">
<frame src="http://www.care4you.in">
<frame src="http://www.curtainoutlook.com">



An HTML document that describes frame layout has a different makeup than an HTML document without frames. A standard document has one HEAD section and one BODY. A frameset document has a HEAD, and a frameset in place of the body.

The frameset section of a document specifies the layout of views in the main user agent window. In addition, the frameset section can contain a noframes element to provide alternate content for user agents that do not support frames or are configured not to display frames.

Elements that might normally be placed in the body element must not appear before the first frameset element or the first frameset element or the frameset will be ignored.