HTML & CSS
- What is the difference between frame and iframe?
- Which one is best?
- Which situation we can use frame and iframe?
- These are deprecated tags?
A frame is part of a frameset, an iframe is an inline frame element.
I think of a frameset as a kind of table layout, each frame being a part of a defined "grid", where iframes can be positioned using CSS
Best? It depends on what you need. I think frames became popular for static pages before backend "includes" became widely used. That is, a page might have header, nav links, footer, and content frames, where the content frame changed so every "page" had the same header, nav links, and footer, without the need to recode them for multiple pages. You could do the same kind of thing with iframes if you wanted to.
You can use frames if you use the frameset doctype, iframes anytime.
I don't know the why behind frameset being deprecated, but iframe is deprecated in favor of using the object tag instead. The problem is that although iframe is deprecated, it's still widely supported, and personally I find the object tag a bit more trouble to work with (though I use neither).
Well accessibility for one reason, the use of frames has been proven to make browsing the website on some devices as impossible, also having pages embedded inside pages... it also has a dark undertone of trying to cover up some potentially dangerous coding.
With frames you need one more HTML page than you have frames - one to go in each frame and one to define the frameset that contains the frames. To do the same layout using iframes requires one less HTML page since the page containing the iframes can also contain the fixed part of what you want displayed.
Basically anything that can be done with frames can also be done using iframes with using fewer files to define what to display.
I personally wouldn't use frames anymore, it just seems outdated. Although it's easy to implement for a case where you have to load a document in a window that uses up the entire area as defined for that frame in a frameset. It can get tricky to get an iframe to use up the entire window height, because you have to dynamically determine what that height is at any given moment.
With iframes, you can easily assign a fixed width/height if you want to just include the external document in a well-defined smaller area of the page.
Iframes come in handy if you want to absolutely position different documents on top of each other and reveal them via tabs as needed for example to allow for quick switching between documents without reloading or relying on AJAX.
Iframes are still more consistently supported than the object element and are not necessarily deprecated (only in strict DTD, but not transitional). Also, framesets are not deprecated either, they have their own DTD.
As per i know an inline frame is just a frame within a single page usually containing another page - it can exist without having a frame set defined and Frames are a bunch of 'boxes' put together to make one site with many pages....
This topic is now closed. New replies are no longer allowed.