The Ins and Outs of Iframes
(Page 1 of 4 )
The term "iframes" is short for "inline frames." Maybe you have never heard of iframes, or maybe you have avoided them because the name incorporates the "F" word, i.e. "frames," which are said to do bad things like confuse search engines. If so, this article will introduce you to a very useful and versatile web design tool that you have been missing out on. If you have already used iframes, but for only basic things, this article will show you some powerful new uses, such as remote scripting.
Introduction
Only basic HTML is required for this two-part article. Some knowledge of PHP and JavaScript would be helpful in understanding the more sophisticated uses of iframes that are explained, particularly in the second part, but is probably not indispensable.
What are iframes?
The concept is simple: an iframe is like window that you can place anywhere on your web page, through which you can see another web page. In other words, iframes allow you to embed another web page within your web page.
An iframe is created by the HTML tag <iframe>. This tag has a required src attribute to tell the frame which URL to load, and several optional attributes, some of which we will mention as we go along. It uses a closing tag, </iframe>. A message which will only display if iframes are not supported can be placed in between the opening and closing tags like so:
<iframe src="path/mydocument.htm">This Browser Does Not Support iframes</iframe>
The iframe concept, and the iframe tag seem pretty simple, and they are, but the implications of the ability of an iframe to embed another URL are profound. For example, content on a remote web page displayed in the iframe, whether static or dynamically generated, can be made to appear as if it is part of your web page. We will learn more about this, and more, in this two part series.
Next: iframes Questions and Answers >>
More HTML Articles
More By John Best