Working with Frames

html.jpg image

You can use frames to divide your Web pages into sections and allow users to access different pages in your Web site from one screen. Frames serves as valuable tool to help you create a dynamic structure for your Web site. Browser windows typically hold a single frame to display an HTML document. If a page’s content exceeds the size of the frame, scroll bars appear allowing the user to view different parts of the page. With multiple frames, the browser window displays several HTML documents at one time, each frame acting as a separate screen. Each frame can display its own scroll bars to allow users to view different portions of the Web page appearing within the frame.

Ways to Use Frames Frame Advantages Frame Disadvantages
You can find numerous uses for frames with a multi-page Web site. You can use frames to display a fixed page at the top of the screen and scrollable page in the reminder of the screen. For example, you might use a navigation page at the top with the links to pages on your site. When a user clicks a link in the top frame, the frame below displays the content. Or you might use side-by-side frames to display a picture in one frame and text in another. When deciding whether to use frames in your Web site, take time to examine the pros and cons of frames. On the pro side, frames are really helpful with larger Web sites, especially when you want to keepcertain information in view at all times. Frames offer a great way to display a navigation bar in one location without needing to include navigational links on every Web page in your site. Frames can make it easier for users to navigate a large Web site. On the con site, users might not see your frame content as you envision; monitor resolution settings vary and what you think is perfect size for a frame may not be so on another user’s screen. Depending on the Web page, not all page content looks good in smaller frames. Although new browsers support the user of frames, some older versions do not. You may need to design a non-frames version of your site to accommodate users without frame support.


HTML Tags for Frame Elements
Syntax Description
<FRAMESET>...</FRAMESET> Defines the frames structure
<FRAME>...</FRAME> Defines a window (a frame) in a frameset

Steps in creating and configuring frames in your HTML document:

  1. Create Frames
  2. Customized Borders
  3. Control Margins
  4. Prevent Frame Resizing
  5. Target a Link

1. Create Frames

You can use frames to divide the Web browser window into sections. This allows you to display different pages in your site on the screen at the same time. For example, you might use one frame to display a navigational page that helps viewers access other parts of your site, and then show the content of a page in another frame. You can use the <FRAMESET>...</FRAMESET> and <FRAME>...</FRAME> tags to define the frame structure. The <FRAMESET> tag creates a frameset, dividing the window into sections, while the <FRAME> tag specifies which page goes into which frame. You can define the size of each frame using an absolute value, measured in pixels or a relative value measured as percentage.

2. Customized Borders

You can change the thickness of your frame borders using the BORDER attribute. By default, Web browsers display the borders around your frames at a thickness of 6 pixels. You can set your frame borders to another size as well as control the color of the borders.

3.Control Margins

You can control the amount of space that appears between a frame border and the contents of the frame. Using the MARGINWIDTH and MARGINHEIGHT attributes, you can set margins for the top, bottom, left, and right side of your frames. Margin space is measured in pixels.

4. Prevent Frame Resizing

By default, users can resize the frames in your Web page, allowing them to view more information in a frame. You can control your page layout by restricting frame resizing.

5. Target a Link

You can make other pages from your Web site appear in a frame in addition to the initial frameset content. To target links to a particular frames, you must identify each frame with a unique name.

Go to top