Attributes of the Frame Tag

Modifying Your Frames

When you create a framed page, the page that shows up in the URL has no real content (unless you have a <noframes> version). Instead, you create <frame> pages which provide the information for your page.

Possible Attributes

  • src: This is the only required attribute for the frame tag. The value of this attribute is the URL of the document you would like to be displayed in the frame. You can reference any HTML object, image, or multimedia element that could normally be displayed by a Web browser. (Keep in mind, if you use an image, it will not be tiled like a background image, but rather just displayed once.)
  • name: This allows you to label your frames so that you can open new pages in specific frames. If you do not name your frames, all links will open in the frame that they are in.
  • noresize: When you set the size of your frames, your readers can come in and change that size to suit them, unless you use the noresize attribute. This allows you to keep control of the layout of your page.
  • scrolling: This attribute dictates the behavior of a scrollbar on your frames. If the frame is larger than the browser window, a scrollbar will appear. If you never want the scrollbars to appear, put scrolling=no in your frame tag. The "yes" option dictates that there will always be a scrollbar on the frame, even if there is nowhere to scroll.
  • marginheight: This attribute defines how tall the margin between frames will be. It cannot be less than 1 pixel. Also, if the browser cannot display the desired values, then this attribute will be ignored.
  • marginwidth: This attribute defines how wide the margin between frames will be. It cannot be less than 1 pixel. Also, if the browser cannot display the desired values, then this attribute will be ignored.
  • frameborder: This attribute allows you to add or remove borders from a single frame on your page. Use the values "yes" or "1" to enable borders and "no" or "0" to disable borders. This attribute is handled differently in IE and Netscape, so if you want to use it, you should define the borders in all frames in your frameset so that you get a consistent view.

    Noframes Content

    This tag allows readers without frames-enabled browsers to view your page. The most common use of this tag is to dictate what browser people should use; however, it's really easy to direct people to the first page of your frameset within the noframes tag. Just add in:

    <noframes>
    This document is framed, however, you can view the page at <a href="home.html">home.html</a>
    </noframes>

    If you're willing to spend a small amount of extra time, you can copy in the contents of your main page into the <noframes> portion of your frameset. This will result in very little loss of quality for your frameless readers.

    Learn more about frames with these advanced techniques or read about iframes in HTML 5.