Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I use HTML frames?

Tags:

I have heard countless reasons on why not to use HTML frames, from their lack of accessibility, the general lacking in UX, their being completely inefficient/unmaintainable, or them just being outdated.

This all brings me to two questions:

  1. Does this general consensus of hate apply to iframes as well?
  2. In what scenario(s) is it acceptable to use frames/iframes in your code?
like image 486
Moses Avatar asked Sep 15 '10 21:09

Moses


People also ask

When should you use frames?

HTML frames are used to divide your browser window into multiple sections where each section can load a separate HTML document. A collection of frames in the browser window is known as a frameset. The window is divided into frames in a similar way the tables are organized: into rows and columns.

Should I use HTML frames?

Frames have been deprecated and should no longer be used. The <iframe> creates an inline frame, which embeds an independent HTML document into the current document.

Are HTML frames deprecated?

Frames are now deprecated in HTML5, but the ability to place one document inside another still exists. You can do this in an [ ](/tags/iframe/). And it is important to realize that is not simply a renamed or updated version of . An is an “inline” frame (or, some would call it, and “internal frame).

Why HTML frame should not be used while designing website?

For example, frames can reduce the amount of usable space on a page, they make it difficult or impossible for users to link directly to or bookmark a specific page within a frameset, and they often prevent users' Back buttons from working as expected.


2 Answers

(1) Not inherently. iframes have many use cases that do not suffer from the problems of frames. They're useful any time you want to mix in a document from another security context, or without the scripting and styles that the parent page is using.

However, it is possible to ‘use an iframe like a frame’: to split the page up into separate iframe areas, with cross-frame-links making a navigational mess that doesn't play well with bookmarks, open-in-new-tab etc.

(2) I would not use frames for anything today. There was a limited use case for them keeping hold of large amounts of page content that you don't want to reload on each navigation. But these days we would just use XMLHttpRequest to update part of the page instead.

Even so, without care taken to make page-changing links accessible (using hash-history and having a static-link analogue for each hash-link, linked with real <a>s that response to middle-click et al), a page that updates/navigates itself using XMLHttpRequest will recreate many of the navigational problems of frames, with strongly negative usability, accessibility and SEO implications.

I find it a bit sad that many authors are creating flashy, swooshy, “modern” animated web sites that, by naïvely using jQuery's load() or similar on its own, exhibit all the worst behaviours of ancient, hated frames.

like image 157
bobince Avatar answered Sep 18 '22 13:09

bobince


(1) No. There are legitimate uses for iframes, where there's no reason to use frames today with modern browsers.

(2) Never use frames; there's other better easier solutions available to produce the same effect.

Use iframes only when embedding the whole site is the most logical option. Although rare, there are occasions when this makes sense.

In short, there's a reason why the frame/frameset/noframe tags are taken out of HTML5, but the iframe will carry over.

(example) If site A is obliged to include a page from site B (proxied to appear to come from site A) then site B css and javascript can and usually will completely hose site A. This is a legitimate reason.

like image 23
digitaldreamer Avatar answered Sep 19 '22 13:09

digitaldreamer