Simple HTML and CSS
Frames
Frames
let you split the screen into rectangular areas, and show different
content in each area. That is useful if you want to keep a menu
visible at all times, like at the top or side of the screen, while
the rest of the screen shows the content invoked through that menu.
A HTML file that specifies the frame structure has a frameset tag
where normal files have the body tag. It divides the screen into
two of more horizontal parts, or into two or more vertical areas.
Within the frameset you put frame tags, each of which refers to a
separate HTML file, which contains the content for that area of the
screen.
Nested framesets: A frameset can be within another frameset, which
means a vertical part of the screen can be subdivided horizontally,
or a horizontal part can be subdivided vertically.
A frameset tag might look like this:
<frameset rows="15%,85%">
<Frame NAME="upper" SRC="upper.htm">
<frameset cols="20%,80%">
<Frame NAME="left" SRC="left.htm">
<Frame NAME="text" SRC="text.htm">
</frameset>
</frameset>
In addition to NAME and SRC other options are
possible, like frameborder, marginwidth, marginheight, noresize and
scrolling. For details see
the
specification by the
World Wide Web consortium,
chapter 16.2.2, or this
explanation
in the Dutch language site
Handleiding HTML, by
Hans de Jong.
Some sources recommend to add a <noframes> tag, for browsers that
do not support frames. But there are hardly any browsers around any
more without the ability to display frames. Even the non-graphical
browser lynx,
which cannot visually show frame content, still makes it accessible,
even if there is no <noframes>.
This means <noframes> is probably unnecessary.
A disadvantage of frames is that they make it difficult to handle hyperlinks.
-
Suppose you are at the beginning of a site, which has a left and a
right screen half. There is a link in that right half, which invokes
some other text. Now if you tell somebody else about that web address
(the URI), as it is displayed by the browser, that person doesn't get
to see what you see. That's because the content invoked by the link
isn't already there.
This problem can be solved by always hyperlinking to another frameset
file, that largely refers to the same HTML files, except for one.
But that soon requires lots of frameset files, which makes the site
difficult to maintain.
-
A link to a completely different site will display content in the
frame in which the link is. This is usually not what you want, especially
not if the link is to somebody else's frameset file. This can be remedied
by adding TARGET=_top in the hyperlink, like this:
<A TARGET=_top HREF="here the URI">text
of the hyperlink</A>
This makes the linked-to content appear all over the screen.
-
TARGET also lets you display content in one screen area, through a link
in another screen area. In that case the target you specify after
TARGET= is the name you mentioned after <frame NAME= .
In this sample site I use this feature in upper.htm, which has links
to invoke texts to be display in the lower right screen area.
-
This link
describes pros, but especially cons, of frames.
-
Attention: Under strict
HTML 4.0.1, TARGET is no longer allowed, probably because of these disadvantages.
OBJECT could be a replacement for Frames, but browsers implement that so differently
and inappropriately, that they are unusable for any practical purposes.
Therefore you might consider discarding of frames altogether. A menu that stays
in sight all the time (the primary reason for using frames at all) could then
be replaced by a single hyperlink on every page (probably at the top
and the bottom, which calls that menu. That means it is not
always visible, but it is at your fingertips, provided all pages are short.
Previous
Start