<iframe> iframe Element - (X)HTML Element Reference :: webDev

<iframe>


					<iframe align=" { bottom | left | middle | right | top } " 
						frameborder=" { 0 | 1 } " height="height of window in pixels or percentage" 
						longdesc="Long description of iframe content" marginheight="Height in pixels" 
						marginwidth="Width in pixels" name="Unique name identifier for frame" 
						noresize="noresize" scrolling=" { auto | no | yes } " 
						src="Source of frame contents" width="width of window in pixels or percentage">
					</iframe>
				

In a <frameset>, the individual windows (or frames) can only be laid in rows or columns, although in days gone by developers found cunning (read: overcomplicated) ways of creating pages where content could appear to be in the middle of a page, apparently floating. Doing this required a complex mess of nested framesets, as if the page were some kind of jigsaw. The <iframe> was the answer to this problem, providing a window that could be placed anywhere within an existing, non frame-based page, much as you could place a <table>or an <img>.

The <iframe> has a number of attributes that are unique to this element (in the context of it being a window/frame), namely it can be given a fixed height and width and also be set to align=""> with surrounding content, much as an <img> can; it also shares some attributes with the <frame>element, namely the longdesc="">,marginheight="">, marginwidth="">, name="">, scrolling=""> and src=""> attributes.

The <iframe> differs from the <frame> in one other way that is worth noting:

  • the <frame> element is self closing, and thus does not contain anything (there is no closing tag). To present content to browser that do not understand/support <frame>s, you use the <noframes> element inside the parent <frameset> element
  • with the <iframe> there is both an opening tag, and there is no requirement for noframes - to present content for browsers that do not understand the <iframe>, you simply place it between these opening and closing tags, as demonstrated in the example HTML
  • Note that <iframe> is not available to use when specifying strict HTML and XHTML doctypes.

<iframe> iframe Element - (X)HTML Element Reference :: webDev