Skip to content

HTML <frame> Tag

The <frame> tag defines a specific window, a frame, where we can load another web page. Use the src attribute to define the address of this web page. The web page can have several such frames.

The <frame> tag is used with the <frameset> element, which defines how to divide the window into frames.

DANGER

The <frame> is a deprecated HTML tag and is not supported in HTML5. Use the <iframe> tag instead.

When using frames, the <frameset> element replaces the <body> tag. The <frameset> element defines the structure of the frameset (zones in the browser window where other web pages are loaded), the number of columns and rows, and their size in percentages or pixels. Note that this tag is also deprecated in HTML5.

TIP

The pages that contain frames can be validated only if the <!DOCTYPE> declaration is set to HTML Frameset DTD or XHTML Frameset DTD.

Use the rows attribute of the <frameset> tag for defining horizontal frames, and the cols attribute for defining vertical frames.

Syntax

The <frame> tag is empty, which means that the closing tag isn’t required. But in XHTML, the <frame> tag must be self-closed (<frame />).

Example of the HTML <frame> tag:

Example of the HTML <frame> Tag

html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <frameset cols="50%,50%">
    <frame src="https://www.w3docs.com/learn-html/html-basic.html">
    <frame src="https://www.w3docs.com/learn-css/css-syntax.html">
  </frameset>
</html>

Result

frame tag example

Example of the HTML <frame> tag with the rows attribute:

Example of the HTML <frame> tag with the "rows" attribute:

html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <frameset rows="30%,30%,40%">
    <frame src="https://www.w3docs.com/learn-javascript.html">
    <frame src="https://www.w3docs.com/learn-php.html">
    <frame src="https://www.w3docs.com/learn-git.html">
  </frameset>
</html>

Advantages and disadvantages of the <frame> tag

Here are the advantages of this tag:

  • It allows viewing several documents inside a single web page.
  • Pages from different servers can be loaded in a single frameset.

The <frame> tag has the following disadvantages:

  • It doesn’t allow bookmarking the web pages that are inside a frame.
  • Using too many frames will cause a high workload on the server.
  • It is not supported by many old browsers.

Frames vs iframes

The <frame> and <iframe> elements have similar behaviour. However, there are some differences between them. The <frame> tag is used with the <frameset> element, which defines how to divide the window into frames. Each of these frames has its content. The <iframe> tag inserts the frame directly into the same row with the other elements of the web page.

Attributes

AttributeValueDescription
bordercolorcolorDefines the color of the border around the frame. Not supported in HTML 5.
frameborder0, 1Defines if the border around the frame should be displayed or not. Not supported in HTML 5.
longdescURLDefines a page which has a long content description of a frame. Not supported in HTML 5.
marginheightpixelsDefines top and bottom margins of a frame. Not supported in HTML 5.
marginwidthpixelsDefines left and right margins of a frame. Not supported in HTML 5.
nametextDefines the name of a frame. (It is recommended to always set this attribute, especially in cases when it is necessary to upload a document to another via a link from one frame.) Not supported in HTML 5.
noresizenoresizeDefines if the user can change the frame size or not. Not supported in HTML 5.
scrollingyes, no, autoDefines if the scroll bar should be displayed or not. Not supported in HTML 5.
srcURLDefines the URL of the page, which should be loaded in the frame. Not supported in HTML 5.

The <frame> element also supports the Global Attributes.

Practice

Which of the following statements are true regarding the HTML <frame> tag?

Dual-run preview — compare with live Symfony routes.