Why were frames deprecated 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)?
There's a couple of misconceptions in your post. First, the
frameset elements are not deprecated in HTML5, they're obsolete (i.e., they've been removed entirely).
frameset elements are not the same thing as the
iframe element, nor do they give the same output:
framesetelement 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.
iframeelement, 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
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.
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.
Frames (frameset) acts as document. It's removed because it breaks HTML documents structure and navigation. Eg. you have links in one frame, content in the other, you can't open link from the page in in a new window, you can't link to specific sub-page, etc.
On the other hand iframes won't break anything if used correctly because they're meant to sandbox content (eg. ads).
Framesets are often used in a way where they break the fundamental principle of the web, that each document has a single URL. This leads to problems with linking, bookmarks, search engines etc.
Typical use of a frameset would be a frame on top with a logo or header, a frame at the side with a menu, and a content frame. But search engines index individual pages, so when you find some page in google, it would like directly to the content page without the frameset, so you lose the navigation. The problem with links and bookmarks is you would typically want to link or bookmark a particular content page inside the frameset, without losing the frameset itself. The is no easy way to do that.
The reason framesets became popular in the first place was because they allowed a statically positioned header and menu with a scrolling content area. But that can be achieved much easier with CSS today. Furthermore frames allowed you to use common elements like logos and menus on multiple pages without using any server-side coding. This was an advantage at at time where server-side coding where tedious and error prone (cgi-scripts!), and many hosts didn't allows server-side scripting at all. Today with CMS'es and better server-side platforms this is much better handled at the server side.
So basically there are no advantages to frameset but lots of problems.
IFrames can be used the same way that framesets were used, and in that case they also lead to the same problems. But there are also many legitimate uses of iframes which does not lead to the same problems.
protected by gnat Aug 30 '15 at 18:32
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?