XHTML » Tags » frame

Syntax:
<frame />

The frame tag is used to create one frame, which is simply a window within another window. As an example, if you want three frames (windows) to appear on an HTML page, you must have three frame tags and the frameset element must set the spacing for three frames.

The frame tags can only occur between an opening and closing frameset element.
 
A frame element displays content, including forms, images, multimedia, other frames, tables, etc. It is very important to understand that the only way to assign content to a frame is to assign a URL using the src attribute. Whatever content is displayable at the referenced URL will in turn be displayed inside the frame.
 
The frames can have either a column (vertical) or a row (horizontal) configuration, but not both. The configuration must be set using either the cols or the rows attribute of the frameset tag, but not both. The order of the frame tags sets the order of the frames. If they are in a rows configuration, the first frame element is the top window, the second frame element is second from the top, etc. For the cols configuration, the order is left to right.
 
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).
 
This tag is self-closing tag. The blank space before the slash (/) is recommended for maximum browser compatibilty.
 

Examples

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DevGuru XHTML frame Tag Example</title>
</head>
<body>
<html>
<head>
<title>frames 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): XHTML

See Also: