HTML and CSS Reference
Because the information displayed on the page is separated into individual frames, the
contents of a single frame can be updated without affecting the contents of any other
frame. If you click one of the linked images in the left frame, for example, the contents
of the large frame on the right are automatically updated to display the details about the
subject you've selected. When this update occurs, the contents of the left frame and the
bottom frame aren't affected.
Before you learn how to use frames, you need to learn about the target attribute of the
<a> tag. It enables you to direct a link to open a page in a different frame or window, and
learning how to use it is necessary to build sites with frames that work. This attribute
takes the following form:
target =“ window_name ”
Usually, when you click a hyperlink, the page to which you're linking replaces the cur-
rent page in the browser window. When you use the target attribute, you can open links
in new windows, or in existing windows other than the one that the link is in. With
frames, you can use the target attribute to display the linked page in a different frame.
The target attribute tells the web browser to display the information pointed to by a
hyperlink in a window called window_name . Basically, you can call the new window
anything you want, except that you can't use names that start with an underscore ( _ ).
These names are reserved for a set of special target values that you'll learn about later
in the “Magic target Names” section.
When you use the target attribute inside an <a> tag, the browser first checks whether a
window with the name window_name exists. If it does, the document pointed to by the
hyperlink replaces the current contents of window_name . On the other hand, if no win-
dow called window_name currently exists, a new browser window opens with that name
assigned to it. Then the document pointed to by the hyperlink is loaded into the newly
Task: Exercise 17.1: Working with Windows
Framesets rely on the target attribute to load pages into specific frames in a frameset.
Each of the hyperlinks in the following exercise uses the target attribute to open a web
page in a different browser window. The concepts you'll learn here will help you under-
stand later how targeted hyperlinks work in a frameset.