Description
The HTML element <frame>
is used to define a single frame in a frameset element.
The element <frameset>
can have one or more <frame>
elements, each having its own attributes for borders, ability to scroll, ability to resize, etc.,
This element is not supported in HTML5 and you should avoid using it in the markup. Instead, use the <iframe>
element.
The below table summarizes its usage.
Usage Details | |
Placement | It is displayed as a Block element and must always be a child of <frameset> element. |
Contents | None. It is an empty element. |
Tags | Opening tag: required; Closing tag: forbidden |
Versions | HTML 4, 4.01 This element is deprecated in HTML 4.01 and obsolete since HTML5, so avoid using this element in your markup. Instead, use the <iframe> element. |
Syntax
Here is the basic syntax of the <frame>
element.
<frame src="URL">
Examples
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example - HTML Element frame</title>
</head>
<body>
<!-- This elements frame and frameset are obsolete and not valid in HTML5, so avoid using them in your markup -->
<frameset rows="*,*">
<frame src="https://www.randomcodez.com" name="home">
<frame src="https://www.randomcodez.com/about" name="about">
</frameset>
<!-- Alternative and better way is to use iframe element as shown below. -->
<iframe src="https://www.randomcodez.com/about" height="300" width="400"></iframe>
</body>
</html>
Attributes
The following table shows the list of supported and unsupported attributes for the <frame>
element.
Attribute Type | Details |
Element-Specific Attributes | The tag <frame> has some element-specific attributes listed in the below table. |
Global Attributes | Like all other HTML tags, the tag <frame> supports the HTML Global Attributes. |
Event Attributes | The tag <frame> also supports the HTML Event Attributes. |
Here is a list of attributes that are specific to the <frame>
element.
Attribute | Value | Required | Description |
src |
URL | Yes | Specifies the path or location of a document to be shown inside the frame. |
frameborder |
0, 1 | No | Instructs the browser whether to display the border or not around the frame. The default value is 1, which displays the border. |
longdesc |
URL | No | Specifies a link to a long description of the frame. |
marginheight |
pixels | No | Specifies the amount of space to be left between the frame's contents in its top and bottom margins. |
marginwidth |
pixels | No | Specifies the amount of space to be left between the frame's contents in its left and right margins. |
name |
text | No | Assigns a name to the current frame. |
noresize |
noresize |
No | This boolean attribute specifies that the frame window is not resizable by the users. |
scrolling |
yes, no, auto | No | Specifies whether overflowing content in frame causes scroll bars to appear or not. |
Browser Compatibility
The tag <frame>
is supported in all modern browsers.
- Google Chrome 1+
- Internet Explorer or Edge 3+
- Firefox 1+
- Apple Safari 1+
- Opera 4+