HTML <frame> tag is used to divide web browser windows into multiple sections, each capable of loading content independently. This is achieved using a collection of frames within a frameset tag.
Note: The <frame> tag is deprecated in HTML 5.
html
<!DOCTYPE html>
<html>
<body>
<frameset rows="20%, 60%, 20%">
<frame name="top"
src="./attr1.html" />
<frame name="main"
src="./gradient.html" />
<frame name="bottom"
src="./colLast.html" />
<noframes>
<p>The browser you are using does not support frames.</p>
</noframes>
</frameset>
</body>
</html>
The above example basically used to create three horizontal frames i.e. top, middle and bottom using row attribute of frameset tag and the noframe tag is used for those browser who doesn’t support noframe.
Syntax
<frameset cols="50%, 50%">
<frame src="page1.html">
<frame src="page2.html">
</frameset>
HTML frame Tag Attributes
HTML <frame> name Attribute
This attribute is used to give names to the frame. It differentiate one frame from another. It is also used to indicate which frame a document should loaded into.
Example
<frame name = "top" src = "C:/Users/dharam/Desktop/attr1.png" />
<frame name = "main" src = "C:/Users/dharam/Desktop/gradient3.png" />
<frame name = "bottom" src = "C:/Users/dharam/Desktop/col_last.png" />
Here we use three frames with names as left center and right.
This attribute in frame tag is basically used to define the source file that should be loaded into the frame.The value of src can be any url.
Example
<frame name = "left" src = "/html/left.htm" />
In the above example name of frame is left and source file will be loaded from “/html/left.htm” in frame.
This attribute in frame tag is used to specify width of the spaces in pixels between the border and contents of left and right frame.
Example
<frame marginwidth="20">
This attribute in frame tag is used to specify height of the spaces in pixels between the border and contents of top and bottom frame.
Example
<frame marginheight="20">
To control the appearance of scroll bar in frame use scrollbar attribute in frame tag. This is basically used to control the appearance of scrollbar. The value of this attribute can be yes, no, auto. Where the value no denotes there will be no appearance of scroll bar.
Example
<frame scrollbar="no">
HTML <frame> Tag – FAQs
Why is the <frame> tag deprecated?
The <frame> tag is deprecated because it causes significant usability, accessibility, and SEO issues. It has been replaced by more modern approaches like <iframe> and CSS for layout purposes.
What replaced the <frame> and <frameset> tags in HTML5?
The <iframe> tag and modern layout techniques like Flexbox and CSS Grid have replaced the <frame> and <frameset> tags. <iframe> allows embedding content while maintaining modern web standards.
What attributes were commonly used with the <frame> tag?
Common attributes included:
- src: Specifies the URL of the content to be displayed in the frame.
- name: Gives the frame a name, allowing links to target that frame.
- scrolling: Controls whether scrollbars appear (values: “yes”, “no”, “auto”).
- noresize: Prevents the user from resizing the frame.
How does the <frame> tag differ from the <iframe> tag?
The <frame> tag is used within a <frameset> to define sections of a page, while the <iframe> tag is used to embed content within a single page. <iframe> is more versatile and compatible with modern HTML5 standards.
How did the <frame> tag impact website navigation?
The <frame> tag often led to confusing navigation because each frame could independently load different content, making it difficult for users to bookmark specific pages or use the browser’s back/forward buttons effectively.