in HTML5 the iframe has new attributes like 'seamless' that should remove borders and scrollbars. I've tried it but doesn't seem to work, I still can see scrollbars and borders (I'm using Google Chrome as browser), Here's my code:
<iframe seamless="seamless" title="google" width="600" height="300" src="http://www.google.co.uk"></iframe>
Any idea why it's not working?
One more question, is it possible to target a specific section of the page inside the iframe?
iO8 has removed support for the iframe seamless attribute.
Full Details and performance review of other iOS 8 changes:
Use the frameborder attribute on your iframe and set it to frameborder="0" . That produces the seamless look. Now you maybe saying I want the nested iframe to control rather I have scroll bars. Then you need to whip up a JavaScript script file that calculates height minus any headers and set the height. Debounce is javascript plugin needed to make sure resize works appropriately in older browsers and sometimes chrome. That will get you in the right direction.
I thought this might be useful to someone:
in chrome version 32, a 2-pixels border automatically appears around iframes without the seamless attribute. It can be easily removed by adding this CSS rule:
Chrome uses the same selector with these default user-agent styles:
You only need to write
in your code. There is not need for:
I just found this out myself.
EDIT - this does not remove scrollbars. Strangely
It's not supported correctly yet.
Chrome 31 (and possibly an earlier version) supports some parts of the attribute, but it is not fully supported.
Updated: October 2016
The
seamless
attribute no longer exists. It was originally pitched to be included in the first HTML5 spec, but subsequently dropped. An unrelated attribute of the same name made a brief cameo in the HTML5.1 draft, but that too was ditched mid-2016:In other words: purge the
seamless
attribute from your memory, and pretend it never existed.For posterity's sake, here's my original answer from five years ago:
Original answer: April 2011
The attribute is in draft mode at the moment. For that reason, none of the current browsers are supporting it yet (as the implementation is subject to change). In the meantime, it's best just to use CSS to strip the borders/scrollbars from the iframe:
There's more to the seamless attribute than what can be added with CSS: part of the reasoning behind the attribute was to allow nested content to inherit the same styles applied to the iframe (acting as though the embedded document was one big nested inside the element, for example).
Lastly, versions of Internet Explorer (8 and earlier) require additional attributes in order to remove the borders, scrollbars and background colour:
Naturally, this doesn't validate. So it's up to you how to handle it. My (picky) approach would be to sniff the agent string and add the attributes for IE versions earlier than 9.
Hope that helps. :)