I have an iframe on an HTML5 document. when I validate I am getting an error telling me that the attribute on the iframe frameBorder
is obsolete and to use CSS instead.
I have this attribute frameBorder="0"
here because it was the only way I could figure out how to get rid of the border in IE, I tried border:none;
in CSS with no luck. Is there a compliant way to fix this?
Thanks.
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 purpose of the HTML frameborder attribute is to specify whether or not to display a border around a frame. The value of this attribute can be set to “1” or “0”. Supported elements. HTML frameborder attribute supports frame and iframe elements.
The frameborder attribute specifies whether or not to display a border around a frame. Tip: For practical reasons, it may be better not to specify borders, and use CSS to apply border styles and color instead. CSS Example: frame borders.
The HTML Iframe frameborder Attribute is used to specify whether or not to display the border around the content of an <Iframe> Element. Syntax: <iframe frameborder="1 | 0"> Attribute Values: 0: It has a Default value. It sets the border on one state.
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:
frameborder
, just to be sure it works (for now)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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With