HTML5 and frameborder
HTML 5 doesn't support attributes such as frameborder, scrolling, marginwidth, and marginheight (which were supported in HTML 4.01). Instead, the HTML 5 specification has introduced the seamless attribute. The seamless attribute allows the inline frame to appear as though it is being rendered as part of the containing document. For example, borders and scrollbars will not appear.
According to MDN
frameborder
Obsolete since HTML5The value
1
(the default) draws a border around this frame. The value0
removes the border around this frame, but you should instead use the CSS property border to control borders.
Like the quote above says, you should remove the border with CSS;
either inline (style="border: none;"
) or in your stylesheet (iframe { border: none; }
).
That being said, there doesn't seem to be a single iframe provider that doesn't use frameborder="0"
. Even YouTube still uses the attribute and doesn't even provide a style attribute to make iframes backwards compatible for when frameborder isn't supported anymore. It's safe to say that the attribute isn't going anywhere soon. This leaves you with 3 options:
- Keep using
frameborder
, just to be sure it works (for now) - Use CSS, to do the "right" thing
- Use both. Although this doesn't resolve the incompatibility problem (just like option 1), it does and will work in every browser that has been and will be
As for the previous state of this decade-old answer:
The seamless
attribute has been supported for such a short time (or not at all by some browsers), that MDN doesn't even list it as a deprecated feature. Don't use it and don't get confused by the comments below.
As per the other posting here, the best solution is to use the CSS entry of
style="border:0;"
Since the frameborder
attribute is only necessary for IE, there is another way to get around the validator. This is a lightweight way that doesn't require Javascript or any DOM manipulation.
<!--[if IE]>
<iframe src="source" frameborder="0">?</iframe>
<![endif]-->
<!--[if !IE]>-->
<iframe src="source" style="border:none">?</iframe>
<!-- <![endif]-->
This works
iframe{
border-width: 0px;
}