Frames and framesets

From Seobility Wiki
Jump to: navigation, search

Attention: Since the latest HTML version, HTML5, framesets and frames are considered unwanted elements that you shouldn’t use anymore. At the end of this article, we present modern alternatives to the use of frames.

Introduction and History

Frames and Framesets
Figure: Frames and Framesets - Author: Seobility - License: CC BY-SA 4.0

Framesets and frames originate from the early years of website design. The frame feature, introduced by Netscape in 1996, made it possible to divide a website into different sections. Originally the frameset was used to separate the header and navigation bar of a page from its content. This separation of static parts - navigation and header - from dynamic parts was useful at that time because the internet connection of most users was very limited and the speed was only a fraction of the data transfer rates available today. Therefore, an attempt was made to reload only certain parts of a website, namely those that change while the static parts remain unchanged. This saved data volume and reduced loading time.

Framesets

A frameset is the layout of a web page and is stored in its own HTML file. It contains the number of individual sections as well as the number and size of rows and columns. The corresponding HTML element is called "frameset" and can contain the attributes "cols" and "rows". “cols" defines the number of columns and "rows" the number of rows. The individual columns are separated by a comma. It is possible to format one or more columns or rows "dynamically", i.e. one or more rows adapt to the size of the fixed columns or rows. With col="400,*" you create a frameset with two columns, where the first column is 400 pixels wide and the second column takes up the rest of the frame. The number and size of the rows are defined analogously to the columns. The resulting fields are then filled using HTML.

Frames

A frame is the core of a frameset page. The "frame" element may not be closed by a closing element, but only "inline", i.e. by "/>" at the end of the opening element. In addition, the frame element may only be used within a frameset.

The two main attributes of a frame are "src" and "name". "src" defines the content page to be loaded into the frame. This works the same as with other tags, such as "img". The "name" attribute serves as a destination for links and is therefore essential for navigation. Apart from these two HTML attributes, the following are allowed in a frame element: id, class, style, title, longdesc, frameborder, marginwidth, marginheight, noresize and scrolling.

The HTML attributes frameborder, noresize, and scrolling are specific to the frame element. With "frameborder" you can define a frame for an element, but not all possibilities of CSS are available here. Noresize determines whether users have the option to enlarge or reduce the frame element. With the scrolling attribute, you can define whether a frame contains a scrollbar or not.

Basic code example showing how frames and framesets are used

Basic example of the syntax used for frames and framesets.

Disadvantages of frames

There are certain important disadvantages of frames, some of which include:

  • Framesets and frames originate from a time when most providers did not yet offer a dynamic creation of websites through the use of server-side programming languages. As this is the case today, the classic use case of frames in HTML no longer exists.
  • Since the browser always displays the entire construct and the URL does not change when navigating the page, separating it into several documents means that users cannot bookmark subpages.
  • Frames make the saving/printing of complete pages more cumbersome.
  • Page content found via search engines is displayed without the corresponding navigation. In the worst case, users see only the content of the frame without neighboring elements.
  • In the age of smartphones, tablets, and the like, the fact that frames cannot be positioned with CSS is also considered a major disadvantage that makes it almost impossible to use frame pages on mobile devices.

Importance of frames for SEO

Most search engines, including Google, only pay attention to the "noframes" area on pages with a frameset, which means that a classic frame page cannot be indexed. To prevent the display of content without an appropriate navigation, a JavaScript snippet can be used. However, in general, the use of frames is discouraged. If a website designed with this technology is to be optimized, it’s generally recommended to redesign the site in a mobile-friendly manner, without the use of frames.

Frameset Checker

Check if there are frames on your web page

Modern replacements for frames

HTML5 does not support frames and they should therefore not be used. If you cannot avoid embedding some elements or documents, it is better to use the iframe element in the HTML code. This element is a successor of the frame element, which is often used for the integration of videos. If you only want to get a fixed navigation and thus prevent scrolling to it, you can implement an XHTML and HTML5 compatible solution with CSS and the "position: fixed" attribute. In addition, AJAX, a combination of JavaScript and XML, offers the possibility to dynamically load and adapt individual elements and content on a website.

HTML Iframe

HTML iframes have been a significant part of web design, allowing for the embedding of a webpage within another webpage. The <iframe> tag, which stands for inline frame, is used to insert content from another source, such as a video, map, or a secondary webpage, into the current document. This is generally considered the modern replacement of frames and framesets. The syntax for an iframe is straightforward, with the src attribute specifying the URL of the page to be embedded, and optional attributes like height, width, and title to control its appearance and accessibility. For instance:,

<iframe src="example.html" title="Inline Frame Example"></iframe> 

This would embed the content of "example.html" into the page. Iframes are particularly useful for inserting content that is updated frequently, as they can be refreshed independently of the main page.

Browser Support

While frames and framesets have fallen out of favor due to their limitations and lack of support in HTML5, iframes continue to be widely supported across all modern browsers. This makes them a reliable tool for embedding content and a better alternative to frames and framesets. However, it's important to note that the use of iframes can still pose some challenges, particularly when it comes to search engine optimization (SEO)[1] and accessibility. Therefore, they should be used sparingly and with consideration of their impact on the user experience.

In summary: Frames and framesets FAQs

What are frames and framesets used for in HTML?

Frames and framesets are a technique that allows you to divide a page into static and dynamic elements. If a user refreshes the page, the browser reloads only the dynamic parts.

What is the difference between a frame and a frameset?

Frame describes the single element a page consists of. The frameset contains the individual frames.

What are the disadvantages of frames?

Dividing a page into multiple documents keeps users from bookmarking individual subpages. Another disadvantage is the fact that you cannot position frames using CSS.

Should you still use frames and framesets?

No. HTML5 does not support frames and framesets and no longer recommends using them.

What are alternatives to frames?

A more modern approach is the iframe element. You can also use CSS or AJAX to reach similar results.

References

  1. Google & iFrames: Debunking Myths, Understanding SEO Impact Search Engine Journal. Retrieved 13 November 2020.

Related links

About the author
Seobility S
The Seobility Wiki team consists of seasoned SEOs, digital marketing professionals, and business experts with combined hands-on experience in SEO, online marketing and web development. All our articles went through a multi-level editorial process to provide you with the best possible quality and truly helpful information. Learn more about the people behind the Seobility Wiki.