Frameset
Frame
HTML frames are used to divide your browser window into multiple sections
Each section can load a separate HTML document.
A collection of frames in the browser window is known as a frameset
The window is divided into frames
Creating Frames
To use frames on a page we use <frameset> tag instead of <body> tag
The <frameset> tag defines, how to divide the window into frames
The rows attribute of <frameset> tag defines horizontal frames
cols attribute defines vertical frames
Each frame is indicated by <frame>
<!DOCTYPE html>
Example
<html>
<head> <title>HTML Frames</title> </head>
<frameset rows = "10%,80%,10%">
<frame name = "top" src = "/html/top_frame.htm" />
<frame name = "main" src = "/html/main_frame.htm" />
<frame name = "bottom" src = "/html/bottom_frame.htm" />
<noframes> <body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
<!DOCTYPE html>
Example
<html>
<head> <title>HTML Frames</title> </head>
<frameset cols = "25%,50%,25%">
<frame name = "left" src = "/html/top_frame.htm" />
<frame name = "center" src = "/html/main_frame.htm" />
<frame name = "right" src = "/html/bottom_frame.htm" />
<noframes> <body>Your browser does not support frames.</body>
</noframes>
</frameset> </html>
The <frame> Tag Attributes
[Link] Attribute & Description
src
This attribute is used to give the file name that
1 should be loaded in the frame. Its value can be
any URL. For example, src =
"/html/top_frame.htm" will load an HTML file
available in html directory.
name
This attribute allows you to give a name to a frame.
It is used to indicate which frame a document
2
should be loaded into..
scrolling
This attribute controls the appearance of the
scrollbars that appear on the frame. This takes
3
values either "yes", "no" or "auto". For example
scrolling = "no" means it should not have scroll bars.
Example
<!DOCTYPE html>
<html> <head> <title>HTML Target Frames</title> </head>
<frameset cols = "200, *">
<frame src = "/html/[Link]" name = "menu_page" />
<frame src = "/html/[Link]" name = "main_page" />
<noframes> <body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
[Link]
<!DOCTYPE html>
<html>
<body bgcolor = "#4a7d49">
<a href = "[Link] target = "main_page">Google</a>
<br /> <br />
<a href = "[Link] target = "main_page">Microsoft</a>
<br /> <br />
<a href = "[Link] target = "main_page">BBC News</a> </body>
</html>
[Link]
<!DOCTYPE html>
<html> <body bgcolor = "#b5dcb3">
<h3>This is main page and content from any link will be displayed here.</h3>
<p>So now click any link and see the result.</p>
</body>
</html>