Why There Is No Body Tag in Frameset
If you are unfamiliar with framesets, you may view an HTML document that uses them and wonder where the body tag is. Framesets do not need body tags to display content on a Web page. These HTML elements consist of other tags called frames that allow you to embed external content inside a Web page. Because framesets contain no body tags, it doesn't take much code to place one on a Web page.
-
Framesets Uses
-
Suppose you wished to display three windows on your Web page that displayed content from three different sites. You can do that using a frameset as shown below:
<frameset cols="25%, 25%, 50%">
<frame src="URL1" />
<frame src="URL2" />
<frame src="URL3" />
</frameset>Replace "URL1," "URL2" and "URL3" with the URLs of the sites you wish to display. The three percentage values control the width of the columns that appear in each of the framesets. Change these to any values you like.
No Body Tag
-
As shown in the previous example, framesets do not contain a traditional body tag found in regular HTML documents. Framesets do not need body tags because framesets replace them with frame tags. A frame tag creates a window that points to a resource on the Web. That resource can be a Web page or even an image that you'd like to appear inside your main page. For instance, if you wanted to display a window on your Web page that displayed a live view of the White House website, you could do that by placing it inside a frameset on your Web page.
-
Unsupported Browsers
-
Some Internet surfers may use old browsers that do not support frames. Accommodate those users by adding a <noframes> tag inside your frameset as shown in the following example:
<noframes>This browser does not support frames.</noframes>
Users who cannot view frames will see the message included in the <noframes> tag.
If your document uses an XHTML DOCTYPE, the content inside the <noframes> tag must appear inside a body statement as shown below:
<noframes><body>This browser does not support frames. </body></noframes>
This is the only time you will see a body tag inside a frameset.
Considerations
-
Many Web pages may not fit inside frames that are small. If a page inside a frame exceeds the frame's dimensions, users must scroll to view its content. Site visitors may also have trouble bookmarking interesting content they see in a frameset because browsers bookmark the URL of the page that contains the frameset instead of a frame inside the frameset. Search engines may also fail to discover pages enclosed inside frames that reside in framesets.
-