Are Iframes (Html) Obsolete

Are IFrames (HTML) obsolete?

In my opinion the W3C jumped the gun in dumping iframes from the Strict HTML and XHTML doctypes. In theory you would use the <object> element to add foreign objects to your document, but browser differences and limitations have made this a nonstarter for many developers. With the much-more-pragmatic HTML 5 (which is still a draft), iframes are back and even have two new attributes: seamless, and the intriguing sandbox.

Is it bad practice to use iframes? Can iframes be translated into images in the same way canvases can?

However, iframes are not obsolete, but they are frames. Is it considered bad practice to use them?

Sometimes you have to embed a separate HTML document into another, and that is OK. For the record, HTML5 has an entire section dedicated to embedding external content, of which one of the relevant elements is iframe (W3C HTML5).

Of course, whether something is good or bad practice also highly dependent on your use case, but best-practice questions tend to be quite broad by nature.

Also, can iframes be rendered to data:png/base64 or whatever, in the same way canvases can?

As a matter of fact, yes, although IE does not appear to support data:text/html at the moment:

<iframe src="data:text/html,<!DOCTYPE html><html><body><p>abc"></iframe>

However, this is not the "proper" way to do it (even the validators don't agree on whether the syntax is valid — W3C's Nu validator appears to dislike data:text/html because of all the HTML symbols, while Validator.nu only complains about the unencoded whitespace in the DOCTYPE). For embedding raw HTML, you need to use the new srcdoc attribute instead of src (which has even less browser support):

<iframe srcdoc="<!DOCTYPE html><html><body><p>abc"></iframe>

So, in general, specifying raw HTML for iframes is a bad idea for now, and even once browsers start supporting the srcdoc attribute, you should use that over a data URI with the src attribute.

Frames deprecated in HTML5 but not iFrames

Inline frames are used to embed "plugins" into parts of a page. Seen google maps on a website before? Those are iframes.

Actual frames on the other hand are quite pointless. They're virtually never used in professional websites. If you ever go to a high school you may see IT projects that use frames for "navigation bars" or something. They take up half the page (or however you configure it) and are loaded as a separate page.

Simply put: iframes can be used as plugins. Frames are inelegant and not very useful

Edit:
To be more specific, iframes and frames are quite different.
Using my google maps example, and iframe would should a little box on the page as you're use to it. A plain frame would take half the screen to display (you can set up many frames so that a particular frame is in the middle of the screen, but why do that when you can use an inline frame?)

The frameborder attribute on the iframe element is obsolete. Use CSS instead.

As they state themselves "The frameborder attribute is not supported in HTML5. Use CSS instead."

The equivalent of frameborder in css is border: 0px;. Add it to your iframe in css.

OK, html4 frames are obsolete , but there does not look to be a way to replacement without re-writing your site completely. Or is there?

We have prototyped a mapping from frameset/frame to iframe/div. It looks pretty good. Lots of references in these pages to places where we got help. We have now cranked these changes into the website and we are now frameset/frame FREE!

http://nufosmatic.com/nufosmatic_prototype/iframe_div/

** We got a surprise posting it to the website this morning, but we will work through that also. Turned out to be a "margin" which should have been a "margin-left".

A question of opinion: Are you still using iframes?

Have a look at this SO question: Are IFrames (HTML) obsolete?

In short: They are part of the HTML 5 draft and will be sticking around. If used correctly, I think they are acceptable. :)



Related Topics



Leave a reply



Submit