XHTML » Tags » frameset

Version: 4.0

Compability: Explorer 4, 5 Netscape 4, 6

Syntax:
<frameset> ... </frameset>

The <frameset> tag serves as a container element to hold a collection of frames. This tag determines the number of frames, whether the frames are to be of a column or of a row configuration, and sets the spacing for either case. In fact, you must specify either a column or row configuration using either the rows or cols attribute (but not both).

When you are using the framset tag, you absolutely must not use a body tag. The frameset tag is used in place of the body tag. However, you can use the iframe tag to create inline frames within a body element.

The only tags that are valid inside the frameset tag are the frame, frameset, head, and noframe. Note that you can nest frameset tags inside of frameset tags. Therefore, an HTML document can contain numerous frames. This opens the possibility of creating complex and imaginative page displays (however, always remember to keep the page user friendly).

The separate closing tag is mandatory.

Examples

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DevGuru XHTML frameset Tag Example</title>
</head>
<frameset cols="50%, 50%">
   <noframes>
      To be viewed properly, this page requires frames.
   </noframes>
   <frameset rows="33%, 33%, *">
      <frame src="xhtml_frames_red.html" />
      <frame src="xhtml_frames_orange.html" />
      <frame src="xhtml_frames_yellow.html" />
   </frameset>
   <frameset rows="50%, 50%"
      <frame src="xhtml_frames_green.html" />
      <frame src="xhtml_frames_blue.html" />
   </frameset>
</frameset>
</html>
Explanation:

This example creates five frames, each with a different background color. Note that there is no body tag.

Language(s): HTML

Events

onload

Syntax: onload="action"

The onunload event occurs just before the HTML document is unloaded or removed from viewing (also when the page is refreshed). When this event happens, the code calls a function that performs a desired action. For example, you may want an alert box to appear that provides useful information to the user.

onunload

Syntax: onunload="action"

The onunload event occurs just before the HTML document is unloaded or removed from viewing (also when the page is refreshed). When this event happens, the code calls a function that performs a desired action. For example, you may want an alert box to appear that provides useful information to the user.

See Also: