Skip to main content

HTML Tags

HTML <frame> Tag

Written by Updated HTML <frame> Tag exercises

The frame tag defined one window inside a frameset, each loading its own page. Frames are obsolete, and current browsers do not show them in modern pages. If you need to show another page inside yours today, use an iframe.

The full story of how framesets worked and why they were dropped is in the frameset tag.

Syntax

html

<frameset cols="50%,50%">
  <frame src="left.html">
  <frame src="right.html">
</frameset>

Attributes

AttributeDescription
srcSpecifies the URL of the document to be displayed in the frame.
nameAssigns a name to the frame (used for linking).
scrollingControls whether scrollbars appear (yes, no, or auto).
noresizePrevents resizing of the frame by the user.
frameborderDefines whether the frame has a border (1 or 0).
marginwidthSets the left and right margins of the frame content.
marginheightSets the top and bottom margins of the frame content.

None of these attributes are valid in current HTML.

Example

html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Frame Tag Example</title>
</head>

<!-- Frameset replaces body when using frames -->
<frameset cols="50%,50%">
  <frame src="https://freethings.org.in" name="leftFrame" frameborder="1" scrolling="auto">
  <frame src="https://hindigems.com" name="rightFrame" frameborder="1" scrolling="auto">
</frameset>

<noframes>
  <body>
    <p>Your browser does not support frames. Please use a modern browser.</p>
  </body>
</noframes>
</html>

Browsers dropped <frame> and <frameset> in HTML5, so the example above renders nothing. The same split-view layout is built today with <iframe> elements, which you can run below.

The modern replacement: <iframe>

html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Modern Replacement for Frames</title>
  <style>
    body { margin: 0; font-family: Arial, sans-serif; }
    .frame-row { display: flex; height: 220px; }
    .frame-row iframe { flex: 1; border: 1px solid #cbd5e1; }
  </style>
</head>
<body>
  <div class="frame-row">
    <iframe src="/samples/frame-left.html" title="Left panel"></iframe>
    <iframe src="/samples/frame-right.html" title="Right panel"></iframe>
  </div>
</body>
</html>

Browser Support

Chrome
Edge
Firefox
Safari
Opera
NoNoNoNoNo

Pages with a modern doctype do not display <frame>. Some browsers still render it in very old documents for compatibility.

Good to know

  • The replacement for showing another page is the iframe tag.
  • The replacement for a shared menu on every page is a normal layout built with CSS Grid or Flexbox, with the menu included on each page.

HTML <frame> Tag exercises

Embed one panel

The frame element is gone. Show https://html5andcss3.org/samples/frame-left.html in the page the modern way, named Left panel.

Result

Check your answer to see it here.