HTML frames

HTML frames

  • Frames are the sections created on the window.
  • Each section can load a separate HTML document.
  • The window is divided into frames in a similar way the tables are organized into rows and columns.
  • Frames provide the facility to display multiple HTML document inside one browser window at a time.
  • To create frames, we need <frameset> and <frame> tag.
1. <frameset> tag
  • Collection of frames is called as frameset.
  • If you are using frames on a page then use <frameset> tag instead of <body> tag.
  • The rows attribute of <frameset> tag indicates horizontal frames and cols attribute indicates vertical frames.
Syntax:<frameset>...........</frameset>

<frameset> Tag Attributes:

AttributesDescription
cols (Columns)It specifies how many columns are to be contained in the frameset and the size of each column.
rowsIt works like the 'cols' attribute and takes the same values, but it is used to specify the number of rows in the frameset.
borderIt specifies the width of the border of each frame in pixels. For example; border = “5”. A value of zero means no border.
frameIt specifies whether a three-dimensional border should be displayed between frames. It takes value either 1 (Yes) or 0 (No). For example; frameborder = “0” specifies no border.
framespacingIt specifies the amount of space between frames in a frameset. It can take any integer value. For example; framespacing = “10” means there should be 10 pixels spacing between each frame.

2. <frame> tag
  • <frame> tag is used to define a frame within a <frameset> tag.
  • A frame should be used within a <frameset> tag.
Syntax:<frame src=”frm1.htm”>

<frame> Tag Attributes:

AttributesDescription
srcIt is used to give the file name that should be located in the frame. Its value can be any URL, for example, src= “/html/abc.html”
nameIt allows to give a name to a frame. This attribute is used to indicate that a document should be loaded into a frame.
frameborderIt specifies whether or not the borders of that frame are shown. This attribute overrides the value given in the frameborder attribute on the <frameset> tag if one is given. This can take values either 1 (Yes) or 0 (No).
marginwidthIt allows to specify the width of the space between the left and right of the frame's border and the content. The value is given in pixels. For example; marginwidth = “10”.
marginheightIt allows to specify the height of the space between the top and bottom of the frame's borders and its contents. The value is given in pixels. For example; marginheight = “10”.
noresizeBy default, a user can resize any frame by clicking and dragging on the borders of a frame. It prevents a user from being able to resize the frame. For example; noresize = “noresize”.
scrollingIt controls the appearance of the scrollbars that appear on the frame. It takes values either “Yes”, “No” or “Auto”. For example; scrolling = “no” means it should not have scroll bars.
longdescIt allows to provide a link to another page which contains a long description of the contents of the frame. For example; longdesc = “framedescription.html”

Example: HTML Frame

<!DOCTYPE html>
<html>
     <head>
          <title>HTML Frames Example</title>
     </head>
     <frameset cols="50%,50%">
          <frame src="http://www.careerride.com/test-login.aspx" >
          <frame src="http://careerride.com/" >
     </frameset>
</html>


Output:
frame