840

How would I remove the border from an iframe embedded in my web app? An example of the iframe is:

<iframe src="myURL" width="300" height="300">Browser not compatible.</iframe>

I would like the transition from the content on my page to the contents of the iframe to be seamless, assuming the background colors are consistent. The target browser is IE6 only and unfortunately solutions for others will not help.

sao
  • 1,835
  • 6
  • 21
  • 40
JoelB
  • 349
  • 3
  • 6
  • 11
  • 2
    Just create a class like ".nb {border:none;}" inside the – Jim Apr 07 '16 at 12:27

26 Answers26

1290

Add the frameBorder attribute (note the capital ‘B’).

So it would look like:

<iframe src="myURL" width="300" height="300" frameBorder="0">Browser not compatible.</iframe>
user229044
  • 232,980
  • 40
  • 330
  • 338
David Basarab
  • 72,212
  • 42
  • 129
  • 156
  • 6
    Took me a minute to figure out in JavaScript you just need element.frameBorder=0. no .style and use 0, not '0' – anderspitman Aug 02 '14 at 23:34
  • 28
    When validating the document using [Markup Validation Service](http://validator.w3.org/check) `frameBorder` results in an error as it's not HTML5 compliant: _The frameborder attribute on the iframe element is obsolete. Use CSS instead._ In HTML5 I would set a CSS property of `border:0`. Is there a way to make it backward compatible without causing validation errors? – ᴍᴀᴛᴛ ʙᴀᴋᴇʀ Feb 26 '15 at 11:31
  • 2
    @MatthewT.Baker Sure, see my answer on one of the other many questions about this attribute: http://stackoverflow.com/a/20719286/1016716 Oops, I see I forgot the capital B in there; I'll edit. – Mr Lister Apr 09 '15 at 07:24
  • 1
    Wow @MrLister, it's almost as if I wrote it. Thanks for pointing me in the right direction! – ᴍᴀᴛᴛ ʙᴀᴋᴇʀ Apr 09 '15 at 09:23
  • 17
    @MartinAndersson http://caniuse.com/#feat=iframe-seamless states that it isn't supported at all. – Tim Büthe Jun 19 '15 at 11:19
  • 3
    The answer here is correct, however the comments suggesting usage of the seamless attribute are not longer correct. The seamless attribute has been remove from the specification: https://www.w3.org/TR/2014/REC-html5-20141028/embedded-content-0.html#the-iframe-element – Ron E Oct 18 '16 at 16:49
  • 1
    Yeah,`seamless` is at time of writing (2017-09-11) not very well supported. or at all apparently. – demaniak Sep 11 '17 at 11:53
  • 7
    Note that while the JavaScript property is `frameBorder` with an uppercase B, the HTML attribute has actually always been case insensitive. And in XHTML it should be all lowercase `frameborder`. – Mr Lister Dec 11 '19 at 08:03
183

After going mad trying to remove the border in IE7, I found that the frameBorder attribute is case sensitive.

You have to set the frameBorder attribute with a capital B.

<iframe frameBorder="0"></iframe>
johannchopin
  • 13,720
  • 10
  • 55
  • 101
Adam
  • 2,082
  • 2
  • 19
  • 17
  • 1
    NOTE: frameborder attribute changes in F12 "debugger" will not be shown by IE6. Instead, add attribute in html code. –  Sep 07 '11 at 11:15
  • Note that while the JavaScript property is `frameBorder` with an uppercase B, the HTML attribute has actually always been case insensitive. And in XHTML it should be all lowercase `frameborder`. – Mr Lister Dec 11 '19 at 08:05
127

As per iframe documentation, frameBorder is deprecated and using the "border" CSS attribute is preferred:

<iframe src="test.html" style="width: 100%; height: 400px; border: 0"></iframe>
  • Note CSS border property does not achieve the desired results in IE6, 7 or 8.
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
56

In addition to adding the frameBorder attribute you might want to consider setting the scrolling attribute to "no" to prevent scrollbars from appearing.

<iframe src="myURL" width="300" height="300" frameBorder="0" scrolling="no">Browser not compatible. </iframe > 
xenox
  • 735
  • 5
  • 9
24

For browser specific issues also add frameborder="0" hspace="0" vspace="0" marginheight="0" marginwidth="0" according to Dreamweaver:

<iframe src="test.html" name="banner" width="300" marginwidth="0" height="300" marginheight="0" align="top" scrolling="No" frameborder="0" hspace="0" vspace="0">Browser not compatible. </iframe>
nicael
  • 18,550
  • 13
  • 57
  • 90
Marnix Bras
  • 1
  • 1
  • 3
13

You can use style="border:0;" in your iframe code. That is the recommended way to remove border in HTML5.

Check out my html5 iframe generator tool to customize your iframe without editing code.

Shan Eapen Koshy
  • 2,909
  • 1
  • 28
  • 40
11

Use the HTML iframe frameborder Attribute

http://www.w3schools.com/tags/att_iframe_frameborder.asp

Note: use frameBorder (cap B) for IE, otherwise will not work. But, the iframe frameborder attribute is not supported in HTML5. So, Use CSS instead.

<iframe src="http://example.org" width="200" height="200" style="border:0">

you can also remove scrolling using scrolling attribute http://www.w3schools.com/tags/att_iframe_scrolling.asp

<iframe src="http://example.org" width="200" height="200" scrolling="no" style="border:0">

Also you can use seamless attribute which is new in HTML5. The seamless attribute of the iframe tag is only supported in Opera, Chrome and Safari. When present, it specifies that the iframe should look like it is a part of the containing document (no borders or scrollbars). As of now, The seamless attribute of the tag is only supported in Opera, Chrome and Safari. But in near future it will be the standard solution and will be compatible with all browsers. http://www.w3schools.com/tags/att_iframe_seamless.asp

Shubham Badal
  • 1,125
  • 13
  • 33
11

Style property can be used For HTML5 if you want to remove the boder of your frame or anything you can use the style property. as given below

Code goes here

<iframe src="demo.htm" style="border:none;"></iframe>
Arpan Saini
  • 4,623
  • 1
  • 42
  • 50
9

I tried all of the above and if that doesn't work for you try the below CSS resolved the issue for me. Which just tells the browsers to not add any padding or margin.

* {
  padding:0px;
  margin:0px;
 }
th0ward
  • 285
  • 3
  • 7
9

You can also do it with JavaScript this way. It will find any iframe elements and remove their borders in IE and other browsers (though you can just set a style of "border : none;" in non-IE browsers instead of using JavaScript). AND it will work even if used AFTER the iframe is generated and in place in the document (e.g. iframes that are added in plain HTML and not JavaScript)!

This appears to work because IE creates the border, not on the iframe element as you'd expect, but on the CONTENT of the iframe--after the iframe is created in the BOM. ($@&*#@!!! IE!!!)

Note: The IE part will only work (of course) if the parent window and iframe are from the SAME origin (same domain, port, protocol etc.). Otherwise the script will get "access denied" errors in the IE error console. If that happens, your only option is to set it before it is generated, as others have noted, or use the non-standard frameBorder="0" attribute. (or just let IE look fugly--my current favorite option ;) )

Took me MANY hours of working to the point of despair to figure this out...

Enjoy. :)

// =========================================================================
// Remove borders on iFrames

var iFrameElements = window.document.getElementsByTagName("iframe");
for (var i = 0; i < iFrameElements.length; i++)
{
  iFrameElements[i].frameBorder="0";   //  For other browsers.
  iFrameElements[i].setAttribute("frameBorder", "0");   //  For other browsers (just a backup for the above).
  iFrameElements[i].contentWindow.document.body.style.border="none";   //  For IE.
}
Tomas
  • 5,067
  • 1
  • 35
  • 39
FirstFraktal
  • 358
  • 4
  • 6
8

Add the frameBorder attribute (Capital ‘B’).

<iframe src="myURL" width="300" height="300" frameBorder="0">Browser not compatible. </iframe>
Harden Rahul
  • 930
  • 8
  • 15
7

In your stylesheet add

{
  padding:0px;
  margin:0px;
  border: 0px

}

This is also a viable option.

davethecoder
  • 3,856
  • 4
  • 35
  • 66
Tropilac
  • 47
  • 1
  • 6
7

Either add the frameBorder attribute, or use style with border-width 0px;, or set border style equal to none.

use any one from below 3:

<iframe src="myURL" width="300" height="300" style="border-width:0px;">Browser not compatible.</iframe>

<iframe src="myURL" width="300" height="300" frameborder="0">Browser not compatible.</iframe>

<iframe src="myURL" width="300" height="300" style="border:none;">Browser not compatible.</iframe>
Divya Chugh
  • 1
  • 2
  • 2
6

If the doctype of the page you are placing the iframe on is HTML5 then you can use the seamless attribute like so:

<iframe src="..." seamless="seamless"></iframe>

Mozilla docs on the seamless attribute

David Tuite
  • 22,258
  • 25
  • 106
  • 176
6

If you are using the iFrame to fit the width and height of the entire screen, which I am assuming you are not based on the 300x300 size, you must also set the body margins to "0" like this:

<body style="margin:0px;">
Michael Herr
  • 1
  • 1
  • 1
5
<iframe src="mywebsite" frameborder="0" style="border: 0px solid white;">HTML iFrame is not compatible with your browser</iframe>

This code should work in both HTML 4 and 5.

IamGuest
  • 1
  • 1
  • 1
4

also set border="0px "

 <iframe src="yoururl" width="100%" height="100%" frameBorder="0"></iframe>
4

Try

<iframe src="url" style="border:none;"></iframe>

This will remove the border of your frame.

Amaan Iqbal
  • 761
  • 2
  • 9
  • 25
4

Use this

style="border:none;

Example:

<iframe src="your.html" style="border:none;"></iframe>
4

1.Via Inline Style set border:0

 <iframe src="display_file.html" style="height: 400px; width:
   100%;border: 0;">HTML iFrame is not compatible with your browser
   </iframe>

2. Via Tag Attribute frameBorder Set 0

<iframe src="display_file.html" width="300" height="300" frameborder="0">Browser not compatible.</iframe>

3. if We have multiple I Frame We can give class and Put css in internal or externally.

HTML:

<iframe src="display_file.html" class="no_border_iframe">
    HTML iFrame is not compatible with your browser 
</iframe>

CSS:

<style>
.no_border_iframe{
border: 0; /* or border:none; */
}
</style>
Samir Lakhani
  • 685
  • 10
  • 19
3

To remove border you can use CSS border property to none.

<iframe src="myURL" width="300" height="300" style="border: none">Browser not compatible.</iframe>
2

Its simple just add attribute in iframe tag frameborder = 0 <iframe src="" width="200" height="200" frameborder="0"></iframe>

  • Before answering a question, always read the existing answers. This answer has already been provided. Instead of repeating the answer, vote up the existing answer. Some guidelines for writing good answers can be found [here](https://stackoverflow.com/help/how-to-answer). – dferenc Feb 18 '18 at 21:31
2

for me, adding worked perfectly

.iframe{
box-shadow: none !important;
}

this solution is particularly for a shopify theme I am editing. The shopify theme uses iframes in different ways throughout the whole theme and one of them glitched. I had to go into the css manually and overide the css attribute.

0

I had an issue with bottom white border and i could not fix it with border, margin & padding rules ... So add display:block; because iframe is an inline element.

This takes whitespace in your HTML into account.

menepet
  • 796
  • 13
  • 17
-2
iframe src="XXXXXXXXXXXXXXX"
marginwidth="0" marginheight="0" width="xxx" height="xxx"

Works with Firefox ;)

ndpu
  • 22,225
  • 6
  • 54
  • 69
-3
<iframe src="URL" frameborder="0" width="100%" height="200">
<p>Your browser does not support iframes.</p>
</iframe>

<iframe frameborder="1|0">

(OR)

<iframe src="URL" width="100%" height="300" style="border: none">Your browser 
does not support iframes.</iframe>

The <iframe> frameborder attribute is not supported in HTML5. Use CSS 
instead.
Md Shahriar
  • 2,072
  • 22
  • 11