HTML Frames

Frames were used in old websites to split the browser window into several parts, where each part loaded a different HTML page. They were created with the <frameset> and <frame> tags.

Note: <frameset>, <frame> and <noframes> are obsolete and removed from HTML5. Browsers may not show them at all. Do not use them in new pages. This chapter is only for understanding old code.

How old frames looked

<!-- Old HTML 4 code. Do not use. -->
<frameset cols="25%, 75%">
  <frame src="menu.html">
  <frame src="content.html">
</frameset>

This code split the window into two columns: a menu page on the left (25 percent) and a content page on the right (75 percent). In frames you do not write a <body> tag.


Why frames were removed

  • Search engines could not index the page properly.
  • You could not bookmark a particular state of the site.
  • The back button and printing did not work well.
  • They were bad for accessibility and for mobile screens.

What to use today

Old use of framesModern solution
Menu on one side, content on the otherCSS layout with Flexbox or Grid, see semantic elements
Same header and footer on every pageInclude files with a server language (PHP) or a template system
Show another page inside a pageiframe

Summary

  • Frames (frameset, frame) are obsolete.
  • Use CSS for page layout, and iframe to embed other pages.

Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.