While debugging some layout problem today I was surprised to see that <iframe>
elements have a default display property of inline
.
For me this seems strange, especially considering that you can apply a height
and width
to an <iframe>
that is respected by the browser, which should not be the case for a simple inline-element.
So can anyone explain me the reasoning behind this?
HTML
<iframe id="test"></iframe>
CSS
alert($('#test').css('display'))
https://jsfiddle.net/0tdLr9pq/
Thanks!
Definition and Usage. The <iframe> tag specifies an inline frame. An inline frame is used to embed another document within the current HTML document.
An inline frame (iframe) is a HTML element that loads another HTML page within the document. It essentially puts another webpage within the parent page. They are commonly used for advertisements, embedded videos, web analytics and interactive content.
IFrames are not obsolete, but the reasons for using them are rare. Using IFrames to serve your own content creates a "wall" around accessing the content in that area. For crawlers like Google, It's not immediately clear that cotent in an iframe will be ranked as highly as if the content were simply part of the page.
An inline element does not start on a new line. An inline element only takes up as much width as necessary.
Because the HTML4 spec said so:
The
IFRAME
element allows authors to insert a frame within a block of text. Inserting an inline frame within a section of text is much like inserting an object via theOBJECT
element: they both allow you to insert an HTML document in the middle of another, they may both be aligned with surrounding text, etc.
The "be aligned with surrounding text" part means they shouldn't be block-level by default.
And it's true that, usually, inline elements ignore the height
and width
properties:
10.3.1 Inline, non-replaced elements
The
width
property does not apply.10.6.1 Inline, non-replaced elements
The
height
property does not apply.
But that's not true for replaced elements, like iframe
. This is explained in 10.3.2 and 10.6.2 sections.
IFRAME stand for Inline Frame. See this : http://www.w3.org/TR/html401/present/frames.html#h-16.5
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