[an error occurred while processing this directive] DM 160A : Basic Frameset Tags [an error occurred while processing this directive]

Each frameset needs several basic tags for functionality. Unlike the standard HTML skeleton, a frameset does not have to have <body> tags; you will want to use them anyway.

The <frameset> Tags

The pair of frameset tags contain the information to set up the browser to display frames. Between the opening and closing frameset tag are frame tags (they specify the contents and name of each frame) and the pair of noframes tags (which give browsers that do not support frames some content).

The opening frameset tag for these pages looks like this:

<frameset cols="150,*">

As usual, the first item in the tag is the tag name (frameset) followed by that important space the separates tag names from tag attributes. Next comes an attribute with associated values; cols="150,*". Since there are two values, this tells the browser to subdivide the browser window into two vertical columns. Remember the mantra about HTML pages; the browser reads the page from left to right and top to bottom. In this instance, the browser is instructed to make the left column 150 pixels wide and the right column will take up the rest of the browser. The asterisk (*) stands for "whatever is left." You may have as many columns as you wish; you need a value for each column. You may choose fixed values in pixels or relative values in percents (%).

If you desire a horizontal orientation for your frameset, the frameset tag might look like this:

<frameset rows="150,*">

Note the use of "rows" as an attribute instead of "cols." This example subdivides the browser window into two horizontal rows; the top one is 150 pixels high and the bottom is the remaining portion of the browser window.

You may use both rows and cols in the frameset tag if you wish to make a "grid" of frames. You may also "nest" framesets inside of framesets if it suits your purposes. As with nested lists of tables, often simpler is better.

Once your frameset tag has subdivided the browser into frames, you need to fill them up. For that, use the...

The <frame> Tag

You need a frame tag for each frame you specify in the frameset tag. Note that the frame tag is singular like the image tag or break tag; is has no closing partner. The frame tags for this frameset look like this:

<frame src="nav.shtml" name="navigation">
<frame src="frames.shtml" name="content">

The first frame tag defines the left column, the second the right. Each frame tag must have two attributes, src and name. The src attribute is the path to the HTML document that you want to fill the frame. The name attribute identifies the frame; this is vital so you can click on a link and have the value of the link (href) appear in the frame thereby changing its content. Note that I have named the left frame "navigation" and the right frame "content." These are arbitrary names; they could have been left and right, fred and ethel, Batman and Robin, or any names you desire. Frames may not share the same name.

In a "rows" configuration, the first frame will specify the top frame and the next the bottom frame. In a "rows" and "cols" setup, the frames are specified left to right, row by row.

The <noframes> Tags

The noframes tags contain information you wish the users with frames incapable browsers to receive. Use any of the usual HTML items in this area: body tags, headings, paragraphs, tables, links, forms, etcetera. The code may be as extensive as a regular HTML page.

A secondary reason for the noframes section is that it gives the data collecting spiders from seach engines something to find. Adding links in this section will lead the spiders to the other pages that are displayed in your frameset.

To state it differently, browsers that understand frames ignore the noframes section; browsers that do not understand frames ignore the frameset information and display the content of the noframes section.

The target Attribute

How do you change the content of a frame in the frameset? When you click on a link, the page requested replaces the current content of the browser window or frame. To make the link act differently, add the target attribute to the anchor tag. The target attribute points to where you would like the link to appear. An analogy could be an archer pointing at a target. The link on the left that bring this page to this right frame looks like this:

[<a href="basic_frameset_tags.shtml" target="content">Basic Frame Tags</a>]

Remember the naming of this frame as "content" in the frame section above? This identifies this frame as destination for the target attribute in the anchor code above.

These three tags and one anchor attribute are needed to make and control the basic frameset. As ever, there a many more to be used. Find out more here.

bottom graphic for DM 60A pages