HTML Frames

HTML Frames: Frames in HTML helps you to divide the web browser into multiple sections, where the section will load a separate HTML document. And a collection of frames in the browser window known as “Frameset”. As we said before that windows will be divided into frames in the same way the tables are organized into rows and columns.

Frames In HTML

Creating Frames / How to create frames in HTML?

If you would like to create frames on a webpage we use <frameset> tag instead of <body> tag.  while the rows attribute of the frameset tag defines the horizontal frames and cols attribute defines the vertical frames. And each and every frame in HTML are enclosed by <frame> tag.

Example:



<!DOCTYPE html>
<html>
   <head>
      <title>HTML Frames</title>
   </head>	
   <frameset rows = "10%,80%,10%">
      <frame name = "main" src = "/html/top_frame.htm" />
      <frame name = "top" 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>

HTML Frameset Tag

Tag Attributes Description
cols Specifies how many columns are contained in the frameset and the size of each column.
 rows the attribute works just like the cols attribute and takes the same values, but it is used to specify the rows in the frameset.
border the attribute specifies the width of the border of each frame in pixels
frameborder the attribute specifies whether a three-dimensional border should be displayed between frames.
framespacing the attribute specifies the amount of space between frames in a frameset

HTML Frame Tag Attributes

Tag Attributes Description
src used to give the file name that should be loaded in the frame. Its value can be any URL.
 name allows you to give a name to a frame. It is used to indicate which frame a document should be loaded into
frameborder it overrides the value given in the frameborder attribute on the tag if one is given, and this can take values either 1 (yes) or 0 (no)
marginwidth the attribute allows you to specify the width of the space between the left and right of the frame’s borders and the frame’s content
marginheight allows you to specify the height of the space between the top and bottom of the frame’s borders and its contents
noresize you can resize any frame by clicking and dragging on the borders of a frame. The noresize attribute prevents a user from being able to resize the frame.
scrolling the attribute controls the appearance of the scrollbars that appear on the frame. This takes values either “yes”, “no” or “auto”.
longdesc allows you to provide a link to another page containing a long description of the contents of the frame