HTML | <frame> Tag
HTML frames are used to divide your browser window into multiple sections
where 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 in a similar way the tables are organized:
into rows and columns.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Example of HTML Frames using row attribute</title>
</head>
<frameset rows = "20%, 60%, 20%">
<frame name = "top" src ="[Link]" />
<frame name = "main" src = "[Link]" />
<frame name = "bottom" src ="[Link]" />
</frameset>
</html>
Output: The above example basically used to create three horizontal frames:
top, middle and bottom using row attribute of frameset tag
HTML frameset Tag
The <frameset> tag in HTML is used to define the frameset.
It is used to specify the number of rows and columns in frameset with their
pixel of spaces.
Each element can hold a separate document.
Note: The <frameset> tag is not supported in HTML5.
Syntax:
<frameset cols = "pixels|%|*">
Attributes: The list of frameset attributes are given below:
cols: The cols attribute is used to create vertical frames in a web browser.
This attribute is basically used to define the no. of columns and their size
inside the frameset tag.
rows: The rows attribute is used to create horizontal frames in the web
browser. This attribute is used to define the no. of rows and their size inside
the frameset tag.
border: This attribute of frameset tag defines the width of the border of
each frame in pixels. Zero value is used for no border.
frameborder: This attribute of frameset tag is used to specify whether a
three-dimensional border should be displayed between the frames or not for
this use two values 0 and 1, where 0 defines no border and value 1 signifies
for yes there will be a border.
framespacing: This attribute of frameset tag is used to specify the amount
of spacing between the frames in a frameset. This can take any integer
value as a parameter which basically denotes the value in pixel.
Example 1
<!DOCTYPE html>
<html>
<head>
<title>Frame tag</title>
</head>
<frameset cols="50%,50%">
<frame src="[Link]
<frame src="[Link]
</frameset>
</html>
Output:
Disadvantages of Frames
There are few drawbacks with using frames, so it's never recommended to use
frames in your webpages −
Some smaller devices cannot cope with frames often because their screen
is not big enough to be divided up.
Sometimes your page will be displayed differently on different computers
due to different screen resolution.
The browser's back button might not work as the user hopes.
There are still few browsers that do not support frame technology.
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
and cols attribute defines vertical frames.
Each frame is indicated by <frame> tag and it defines which HTML document
shall open into the frame.
Nested Framesets
The frameset is the collection of frames in the browser window.