I am using various online services to create pages for our site and would like to use iframes for including pages in each other (for example header and footer blocks). I have a lot of blocks of content that I need to repeat across landing pages so using this mechanism is convenient.
Will this cause a problem for search engines visiting our site or for our ranking?
Thanks
B
Yes, of course. Try to avoid using iframes as much as possible.
In your case you may use, include or require functions. For example, if you use PHP:
<?php include('header.html') ?>
Update
If you cannot use PHP or alternatives, consider including HTML inside HTML
It certainly won't help your page in the SEO stakes. It shouldn't penalise you for the iframe per se but you will have a lot of your page content ignored by google. If the iframed content contains your header and footer links, google will ignore them which is a big no no.
Is this practice widespread in existing pages?
If the site runs on a number of html files with iframes and you have no way to use php you might be best served by simply putting the header and footer html in the static html and doing a large scale find and replace whenever you need to change the header or footer.
You are working within the constraints of quite old techniques and competing with people who are able to SEO their sites using modern techniques so if SEO is that important you should sort out the way you build pages or do it the long, hard way.
Yes, the search engines essentially ignore what's inside them. That's unfortunate especially if you have keyword rich content within the iframe. Additionally the overall page will have less content in the eyes of the search engines. Always try to serve up the content you want searched in the presentation layer. Avoid placing text, links, images etc. in the behavior layer as that too is hidden from search engines.
SEOmoz's blogs are a good place to learn http://www.seomoz.org/blog
While not optimal iframes can be used to serve up link heavy or SEO irrelevant content keeping the primary page lighter and more search engine structured, in other words, less diluted.
If the portions of your site in the iframe are essential to navigation or search engine spidering they should be avoided at all costs.
It is also important to note that if you do use iframes for content you should block the search engine from spidering those pages by using a robots.txt. Even if your pages are w3 validated they will appear broken to visotrs landing there via a SERP since the page will only include a small portion of the site markup.
I would like to use my website on mechanical turk.
But because I can only enter static HTML into mechanical turk's description.
I need to somehow place my website there. How do I do that?
You can't effectively do this, with one exception.
See if they permit the iframe element. If they do, then you can use an iframe to reference your web site. Be warned, cookie behavior and other things may cause interaction problems on your site. iframe is also considered a security risk, so I would not be surprised if they don't allow it.
Your actual best bet is going to be merely linking to your site from the description field you're given.
Do iframes still fit the mold of current web standards? The technology is old but I am seeing them resurface - especially with the new youtube embed code being iframes and facebook just allowing custom tabs to be iframes as well.
My question is basically: Are the acceptable?
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. :)
I agree with everyone that they should be a last resort, but there are certain things that demand the use of iframes.
For instance, there's no better way to do ajax file uploading than posting to an iframe and then reacting to the iframe's onload event to handle it.
Yes, my company still uses iFrames to embed third-party content on our site.
They still have a place but, IMHO, should be a last resort.
A lot of components such as Facebook's social widgets or Youtube's embeded player use iframes.
I also use some, when needed. Of course I don't abuse it because it's not adapted for all situations.
I have seen some mails which has HTML content embedded in them. The content of the mail changes as the corresponding webpage in their site change(for example price of stocks which keeps updating in the mail itself). How to link such webpage content into emails?
In other words how to link a web page into an email so that whenever I change the html page, the mail content also changes.
Thanks...
A thought: maybe they are using an image that is downloaded from the server?
As you can't have JavaScript in an email or even most CSS, I'm guessing this might be one of the only ways. I'm pretty sure that one email client or service removes every piece of "special" HTML: iframes, JavaScript, CSS, Flash, etc.
You could place an image in your HTML - which was updated by you on your server.
This may be impossible due to security limitations, but you may be able to use an iframe element.
Not a solution, but a quick answer from my site on this topic as a user: Beside the point that Javascript/Image/IFrame/Flash solutions doesn't reliable work in all email clients, but are a general security risk, I dislike the basic idea of changing the looks of an email after you have send it without the receivers approval. Additionally you make it very easy for the user to be tracked (working hours, locations, view) and that is definitely NOT in the interest of the users. If you have something important or interesting to tell just provide a link to your site plus a short description...
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
The community reviewed whether to reopen this question 6 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
Somewhere along the line I picked up the notion that using iframes is 'bad practice'.
Is this true? What are the pros/cons of using them?
As with all technologies, it has its ups and downs. If you are using an iframe to get around a properly developed site, then of course it is bad practice. However sometimes an iframe is acceptable.
One of the main problems with an iframe has to do with bookmarks and navigation. If you are using it to simply embed a page inside your content, I think that is fine. That is what an iframe is for.
However I've seen iframes abused as well. It should never be used as an integral part of your site, but as a piece of content within a site.
Usually, if you can do it without an iframe, that is a better option. I'm sure others here may have more information or more specific examples, it all comes down to the problem you are trying to solve.
With that said, if you are limited to HTML and have no access to a backend like PHP or ASP.NET etc, sometimes an iframe is your only option.
They're not bad practice, they're just another tool and they add flexibility.
For use as a standard page element... they're good, because they're a simple and reliable way to separate content onto several pages. Especially for user-generated content, it may be useful to "sandbox" internal pages into an iframe so poor markup doesn't affect the main page. The downside is that if you introduce multiple layers of scrolling (one for the browser, one for the iframe) your users will get frustrated. Like adzm said, you don't want to use an iframe for primary navigation, but think about them as a text/markup equivalent to the way a video or another media file would be embedded.
For scripting background events, the choice is generally between a hidden iframe and XmlHttpRequest to load content for the current page. The difference there is that an iframe generates a page load, so you can move back and forward in browser cache with most browsers. Notice that Google, who uses XmlHttpRequest all over the place, also uses iframes in certain cases to allow a user to move back and forward in browser history.
It's 'bad practice' to use them without understanding their drawbacks. Adzm's post sums them up very well.
On the flipside, gmail makes heavy use of iFrames in the background for some of it's cooler features (like the automatic file upload). If you're aware of the limitations of iFrames I don't believe you should feel any compunction about using them.
Having worked with them in many circumstances, I've really come to think that iframe's are the web programming equivalent of the goto statement. That is, something to be generally avoided. Within a site they can be somewhat useful. However, cross-site, they are almost always a bad idea for anything but the simplest of content.
Consider the possibilities ... if used for parameterized content, they've created an interface. And in a professional site, that interface requires an SLA and version management - which are almost always ignored in rush to get online.
If used for active content - frames that host script - then there are the (different) cross domain script restrictions. Some can be hacked, but rarely consistently. And if your framed content has a need to be interactive, it will struggle to do so beyond the frame.
If used with licensed content, then the participating sites are burdened by the need to move entitlement information out of band between the hosts.
So, although, occaisionally useful within a site, they are rather unsuited to mashups. You're far better looking at real portals and portlets. Worse, they are a darling of every web amateur - many a tech manager has siezed on them as a solution to many problems. In fact, they create more.
Based on my experience a positive side for iframe are when calling third party codes, that may involve calling a javascript that calls a has a Document.write(); command. As you may know, these commands cannot be called asynchronously due to how it is parsed (DOM Parser etc). An example of this is http://sourceforge.net/projects/phpadsnew/ I've made use of iframes to help speed up our site as there were multiple calls to phpadsnews and the site was waiting for the response before proceeding to render different parts of the page. with an iframe I was able to allow the site to render other parts of the page and still call the Document.write() command of phpads asynchronously. Preventing and js locking.
There are definitely uses for iframes folks. How else would you put the weather networks widget on your page? The only other way is to grab their XML and parse it, but then of course you need conditions to throw up the pertenant weather graphics... not really worth it, but way cleaner if you have the time.
The original frameset model (Frameset and Frame-elements) were very bad from a usability standpoint. IFrame vas a later invention which didn't have as many problems as the original frameset model, but it does have its drawback.
If you allow the user to navigate inside the IFrame, then links and bookmarks will not work as expected (because you bookmark the URL of the outer page, but not the URL of the iframe).
It's worth noting that iframes will, regardless of the speed of your users' internet connection or the contents of the iframe, cause a small (0.3s or so) but noticeable slowdown in the speed your page downloads. This is not something you'll see when testing it locally. Actually, this is true for any element added to a page, but iframes seem to be worse.
When your main page loads in HTTP protocol and parts of your page need to work in HTTPS protocol, iFrame can beat jsonp hands down.
Especially, if your dataType is not natively json and needs to be translated on server into json and translated on client back into e.g. complex html.
So nope - iFrame is not evil.
They are not bad, but actually helpful. I had a huge problem some time ago where I had to embed my twitter feed and it just wouldn't let md do it on the same page, so I set it on a different page, and put it in as an iframe.
They are also good because all browsers (and phone browsers) support them. They can not be considered a bad practice, as long as you use them correctly.
I have seen IFRAMEs applied very successfully as an easy way to make dynamic context menus, but the target audience of that web-app was only Internet Explorer users.
I would say that it all depends on your requirements. If you wish to make sure your page works equally well on every browser, avoid IFRAMEs. If you are targeting a narrow and well-known audience (eg. on the local Intranet) and you see a benefit in using IFRAMEs then I would say it's OK to do so.