Frames

Frames are a way to show more than one web page simultaneously. Its use is being discouraged. In XHTML 1.1 there is no support for frames. We will discuss frames from the sake of completeness and then see how we can replace them.

The starting point for a document with frames is an HTML page that has the body element replaced with frameset. Here is an example:

<html>
<head>
...
</head>

<frameset rows = "50, *">
  <frame name = "navbar" src = "./nav.html">
  <frame name = "main" src = "./synopsis.html">

  <noframes>
    <body>
      <p>
        This page uses frames. Here is the 
	<a href = "./noframes.html"> no frames </a> version.
      </p>
    </body>
  </noframes>
</frameset>
</html>

Here is the html page for the navigation bar:

<html>
<head>
...
</head>

<body>
  <h2> Magnum Opus </h2>
  [<a href = "./chap1.html" target = "main"> Chapter 1 </a>]
  [<a href = "./chap2.html" target = "main"> Chapter 2 </a>]
  [<a href = "./chap3.html" target = "main"> Chapter 3 </a>]
  [<a href = "./chap4.html" target = "main"> Chapter 4 </a>]
</body>
<html>

Here is the html page for the synopsis:

<html>
<head>
...
</head>

<body>
<h2> Synopsis  </h2>
<p>
  It was a dark and stormy night!
</p>
</body>
<html>

Frames can be nested. Use the element frameset instead of the element frame to achieve the desired level of nesting. The attribute target can have several different types of values. Usually it has the name of the frame where the page is to be displayed.

Here is an example of a regular frame.

Why no Frames

Inline Frame

The iframe element allows authors to insert a frame within a block of text. The contents of the iframe element is displayed only by browsers that do not support frames or are configured not to display frames.
<iframe src = "./foo.html" width = "440" height = "500"
	   scrolling = "auto" frameborder = "1" >
[ Your browser does not support frames or 
  is currently configured not to display 
  frames. However, you may visit
  <a href = "./foo.html" > the related
  document </a> ]
</iframe>

Here is an example of an inline frame.