HTML Frameset Tag - GeeksforGeeks

The HTML <frameset> tag was used in older versions of HTML to create multi-pane layouts within a web page. By dividing the browser window into multiple sections, each frame could display a separate HTML document. This allowed for the creation of complex web layouts with different content in each pane.

Note: The <frameset> tag is deprecated in HTML5 and is no longer supported in modern web development.

What to Use Instead of Frameset?

Instead, more responsive and accessible layout techniques such as CSS Grid and Flexbox are recommended.

Syntax

<frameset cols="pixels|%|*"> <!-- Define frames here --> </frameset>

Attributes

The list of frameset attributes is given below:

AttributeDescription
colsDefines the number of columns and their size within the frameset tag, creating vertical frames in the web browser.
rowsDefines the number of rows and their size within the frameset tag, creating horizontal frames in the web browser.
borderSpecifies the width of the border of each frame in pixels. A value of 0 indicates no border.
frameborderSpecifies whether a three-dimensional border should be displayed between frames. Values: 0 (no border) or 1 (border).
framespacingSpecifies the amount of spacing between frames in a frameset, denoted in pixels.

Examples of the <frameset> Element in HTML

Let’s look at how the <frameset> tag can be used to create both horizontal and vertical frames.

Example 1: In this example we defines a frameset with three rows, each displaying different content from external sources. The frames provide structured layout, with a fallback message for browsers that don’t support frames.

HTML <!DOCTYPE html> <html> <head> <title>frameset attribute</title> </head> <body> <frameset cols="30%, 40%, 30%"> <frame name="top" src="attr1.png" /> <frame name="main" src="gradient3.png" /> <frame name="bottom" src="col_last.png" /> <noframes> <body>The browser you are working does not support frames.</body> </noframes> </frameset> </body> </html>

Output:The above example basically used to create three horizontal frames: top, middle, and bottom using row attribute of frameset tag, and the noframe tag is used for that browser that doesn’t support noframe.

Example 2: In this example we defines a frameset with three columns, each displaying different content from external sources. A fallback message is provided for browsers that don’t support frames.

HTML <!DOCTYPE html> <html> <head> <title>frameset attribute</title> </head> <body> <frameset cols="30%, 40%, 30%"> <frame name="top" src="attr1.png" /> <frame name="main" src="gradient3.png" /> <frame name="bottom" src="col_last.png" /> <noframes> <body>The browser you are working does not support frames.</body> </noframes> </frameset> </body> </html>

Output:The above example basically used to create three vertical frames: left, center, and right using col attribute of frameset tag.

Supported Browsers:

  • Google Chrome
  • Edge
  • Firefox
  • Opera
  • Safari

HTML frameset Tag – FAQs

Why is the <frameset> tag deprecated in HTML5?

The <frameset> tag is deprecated in HTML5 because it presents significant usability, accessibility, and SEO issues.

What is the difference between the <frameset> and <iframe> tags?

The <frameset> tag divides the browser window into multiple frames, with each frame being defined by a <frame> tag. The <iframe> tag, on the other hand, embeds one HTML document within another without the need for a frameset, allowing for more control and flexibility.

Can you nest <frameset> tags?

Yes, you can nest <frameset> tags to create complex layouts. For example, a vertical split can be created with one <frameset> and within one of the sections, you can nest another <frameset> for a horizontal split.

How do you target links to open in a specific frame?

You can target links to open in a specific frame by using the target attribute with the name of the frame.

Can the <frameset> tag be used for responsive design?

No, the <frameset> tag is not suitable for responsive design. Frames are fixed in size and do not adapt well to different screen sizes or devices.

C

Chandu_Siddartha Follow Improve Previous Article HTML <frame> Tag Next Article HTML <head> Tag

Từ khóa » Html5 Tag Frameset