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.

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

If you want to use frames in a web browser instead of the <body> tag, you can put the <frameset> tag. It defines the structure of a frame (zone in the browser window, where we can load another web page), the number of columns and rows, and also how many percent/pixels it will occupy in a frame. But take into account, that this tag is deprecated in HTML5, too.

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

Use the rows attribute of the <frame> 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 closed (<frame/>).

Example of the HTML <frame> tag:

<!DOCTYPE html>
<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:

<!DOCTYPE html>
<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 to view several documents inside of a single Web page.
  • With this tag pages from different servers are loaded in a single frameset.
  • Using this tag will allow to address the browsers that don’t support frames.

The <frame> tag has the following disadvantages:

  • It doesn’t allow to bookmark the Web pages that are inside of 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

Attribute Value Description
bordercolor color Defines the color of the border around the frame.
Not supported in HTML 5.
frameborder 0
1
Defines if the border around the frame should be displayed or not.
Not supported in HTML 5.
longdesc URL Defines a page which has a long content description of a frame.
Not supported in HTML 5.
marginheight pixels Defines top and bottom margins of a frame.
Not supported in HTML 5.
marginwidth pixels Defines left and right margins of a frame.
Not supported in HTML 5.
name text Defines 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.
noresize noresize Defines if the user can change the frame size or not.
Not supported in HTML 5.
scrolling yes
no
auto
Defines if the scroll bar should be displayed or not.
Not supported in HTML 5.
src URL Defines 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.

Browser support

chrome edge firefox safari opera

Practice Your Knowledge

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

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

Do you find this helpful?