Understanding how frames and framesets work
Frames are considered discontinued (deprecated) in todays CSS world!
A frame is a region in a browser window that can display an HTML document independent of what’s being displayed in the rest of the browser window.
A frameset is an HTML file that defines the layout and properties of a set of frames. To view a set of frames in a browser, enter the URL of the frameset file; the browser then opens the relevant documents to display in the frames.
The frameset file for a site is often named index.html, so that it displays by default if a visitor doesn’t specify a filename.
This website shows a frame layout consisting of three frames: one narrow frame on the side that contains a navigation bar, one frame that runs along the top, containing the logo and title of the website, and one large frame (this page) that takes up the rest of the page and contains the main content.
Each of these frames displays a separate HTML document. In my website, the document displayed in the top frame of this never changes as the visitor navigates the site.
The side frame navigation bar contains links; clicking one of these links changes the content of the main content frame, but the contents of the side frame itself remain static.
The main content frame (this page) displays the appropriate document for whichever link the visitor clicks on the left.
Note that a frame is not a file. It’s easy to think of the document that currently appears in a frame as an integral part of the frame, but the document isn’t actually part of the frame. The frame is a container that holds the document -- any frame can display any document. Note: The word page can be used loosely to refer either to a single HTML document or to the entire contents of a browser window at a given moment, even if several HTML documents appear at once.
The phrase "a page that uses frames," for example, usually refers to a set of frames and the documents that initially appear in those frames.
A site that appears in a browser as a single page comprising three frames actually consists of at least four separate HTML documents: the frameset file, plus the three documents containing the content that initially appears in the frames.
Deciding whether to use frames
The most common use of frames is for navigation. A set of frames often includes one frame containing a navigation bar and another frame to display the main content pages. When I first started this web site frames were still in vogue. Also, I was always changing the web site's content so frames made it easy to just add and remove pages without adding a menu to each page.
Designing with frames can be confusing.
Creating a web page without frames accomplishes many of the same goals as a set of frames, is less hassle to set up. Note that making use of frameless pages makes each page carry the menu. So, if you want a navigation bar to appear on the left side of your page, you can either replace your page with a set of frames, or just include the navigation bar on every page in your site
Many professional web designers prefer not to use frames, and many people who browse the web dislike frames. In most cases this dislike is due to having encountered sites that use frames poorly or unnecessarily (such as a frameset that reloads the contents of the navigation frames every time the visitor clicks a navigation button).
When frames are used well (such as when they’re used to keep navigation controls static in one frame while allowing the contents of another frame to change), they can be very useful for some sites. (Example: They work well for the great Pat Martino's web site.)
Not all browsers provide good frame support, and frames may be difficult for visitors with disabilities to navigate, so if you do use frames, always provide a noframes section in your frameset, for visitors who can’t view them. You may also want to provide an explicit link to a frameless version of the site, for visitors whose browsers support frames but who don’t like using frames.
Advantages to using frames include the following
- A visitor’s browser doesn’t need to reload the navigation-related graphics for every page.
- Each frame has its own scroll bar (if the content is too large to fit
in a window), so a visitor can scroll the frames independently.
For example, a visitor who scrolls down to the bottom of a long page of content in a frame doesn’t need to scroll back up to the top to use the navigation bar if the navigation bar is in a different frame.
Disadvantages to using frames include the following
- Precise graphical alignment of elements in different frames can be difficult.
- Testing the navigation can be time-consuming.
- The URLs of the individual framed pages don’t appear in browsers, so it can be difficult for a visitor to bookmark a specific page (unless you provide server code that enables them to load a framed version of a particular page).
