HTML5 – Why Were Frames Removed but Not iFrames?

html5

Why were frames removed in HTML5, but not iFrames? After all, there is almost no difference between the two. In many instances using either of them would give the same output (pardon me if I am wrong)?

Best Answer

There's a couple of misconceptions in your post. First, the frame and frameset elements are not deprecated in HTML5, they're obsolete (i.e., they've been removed entirely).

Second, the frame and frameset elements are not the same thing as the iframe element, nor do they give the same output:

  • The frameset element replaces the body element in pages as a means to include a different document model for web pages: they're bad for usability and accessibility, and what they intended to accomplish have been completely replaced by CSS and ubiquitous server-side development.

  • The iframe element, on the other hand, does not replace the body of a page. It acts as a means to include a new browsing context embedded within a block of content. It does not suffer from the same usability or accessibility problems as the frameset model and is used almost anywhere one needs to include an embedded browsing context (widgets being the most prolific example).1

The iframe in HTML5 also takes on additional features in that it can be sandboxed, allowing the parent document to decide what gets executed within it. This allows for some measure of security for the parent document (and visitors to the parent document) when embedding untrusted content.


Notes

Note 1: the object element somewhat overlaps with the iframe element, but it has a different content model (which is intended mainly for plugins), has its own set of caveats, and doesn't have the sandboxing attributes the iframe element has.

Related Topic