HTML and CSS

Creating a Frameset

First, I want you to focus on learning how to write frameset documents. They are definitely different from the HTML pages you've been exposed to in this tutorial so far. For starters, they use a different DOCTYPE declaration. This is the first piece of unique markup for a frame-based page.

The frameset DOCTYPE declaration for XHTML 1.0

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

Now things start to get really interesting! Instead of the conventional HTML structure you're by now familiar with, you won't be adding a head and a body; instead, you add a head and a frameset.

You'll be able to use the head portion the same way you would in any other documentfor title, script, or stylebut you won't have a body element because the frameset element takes its place for all framed documents. The frameset element (and its corresponding attributes, which we'll get to in just a bit) is the second piece of unique markup for a frame-based page.

Frameset document structure

<!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">
<head>
<title>Frameset Document</title>
</head>
<frameset>

</frameset>
</html>

The third unique element is the frame element, which defines which HTML pages will be placed into the corresponding frames you're creating for your page. The number of frame elements corresponds directly to the number of frames in the page.

Frameset with the minimum required two frame elements

<frameset>
<frame />
<frame />
</frameset>