Chapter 6. Frames

Frames divide a browser window into two or more separate pieces or panes, with each pane containing a separate web page. One of the key advantages that frames offer is that you can load and reload single panes without having to reload the entire contents of the browser window. A collection of frames in the browser window is known as a frameset.

A frameset divides the window into rows and columns (rather like a table). The simplest of framesets might just divide the screen into two rows, whereas a complex frameset could use several rows and columns.

There is also a special kind of frame called an iframe which is a single window that can sit anywhere inside a page.

In this chapter you learn the following:

  • How to create a frameset document with multiple frames

  • How to create inline frames (or iframes), which are single windows that sit within another page

  • How to deal with users whose browsers cannot use frames


I should warn you early on that there are actually very few cases in which most developers consider using frames. I will explain the main reasons why in the second section of this chapter, after showing a simple example that helps you understand what frames are. You are more likely to use iframes, which are covered near the end of the chapter.

Introducing the Frameset

To help you understand frames, let's look at an example. Figure 6-1 shows you a frameset document in a browser. This frameset divides the page into three parts, and each separate part of the page is ...

Get Beginning HTML, XHTML, CSS, and JavaScript® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.