What are HTML Frames?:
HTML frames are a part of the HTML specification that allows you to display multiple Web pages in one browser window all at the same time. You can use frames for navigation or to include blocks of text on multiple pages.
Each document on the screen is a separate HTML document. They are each called a frame.
HTML Frames Examples:
Disadvantages of HTML Frames:
While some people would claim that HTML frames are not part of the specification or that only non-professionals use them. Neither of these statements are true. But there are a few difficulties with HTML frames:
- You have to maintain more documents than you would for a normal Web page. You maintain both the frameset page, and the HTML for the pages the frameset links to.
- Frames can be hard for your customers to print. Most browsers will only print the frame that has focus, which is generally not what the customer wants.
- Frames can be hard for visitors to understand. When they click a link, they expect the URL to change, but frames keep the same URL the entire time.
- Some older browsers have difficulty using the back button correctly within a frameset. If you hit the back button, it takes you completely out of the frameset.
HTML Frames Frameset Tag:
The FRAMESET tag is the tag that builds your frame. You use it instead of a BODY tag on your frameset pages. The attributes of this tag tell the browser how to divide the screen. If you want to divide the screen horizontally, you use rows, vertically you use cols (columns). You can define your frames as actual lengths or as percentages of the screen. The asterisk (*) tells the browser to use all the remaining space for that frame.
HTML Frames Tag:
The FRAME tag provides the details of the Web pages to be used for each frame in the frameset.
Sample HTML for HTML Frames:
This frameset would create a 2 column vertical frameset using 1/4 and 3/4 of the screen for the first and second frame.
<frameset cols="25%,75%"> <frame src="page1.htm"> <frame src="page2.htm"> </frameset>
Using the Noframes Tag with HTML Frames:
Once you've created a frameset, you should create a page that doesn't use frames and put this HTML in the NOFRAMES tag inside your frameset. This will allow user agents, like search engine robots, to find and read your page even if they can't view frames directly.
The NOFRAMES tag is very easy to use. You create an HTML page like normal, and then put everything in the BODY tag into the noframes tag, including the BODY tag. Then put the noframes tag into your FRAMESET tag.
IFrames are HTML Frames Too:
Some people think that iframes are something different from frames, but they really are HTML frames just like the more standard frames are. The difference is that an iframe doesn't need to be inside a frameset to work. You can use iframes to put any HTML page inside any other HTML page.