|
Helping ordinary people create extraordinary websites! |
Iframes: What are they, how to use them and which browsers support themBy Steve Adcock2005-05-14
Inline frame syntax The iframe takes some of the same attributes that any other HTML element takes, like width, height, src and align. Taking our above iframe as our example, here's the code required to pull that off. <iframe src="url/to/document.html" width="100%">The inline frame syntax starts by identifying the name of the element, or 'iframe'. Then, we specify the source file that will be displayed (embedded) within the iframe. I've set the width to 100%, which will span 100% of the main table in this case. The 'Sorry, your browser does not support iframes.' text will only display if the browser does not support the iframe element. Then, we simply end our iframe tag set. While we are looking at the syntax, let's take a look at some of the other attributes that the iframe element supports. • Name: names the iframe elementThe syntax of the iframe is very straight forward. Although you don't have to specify all of these, you must use the 'src' attribute so the iframe knows which document to include. Alignment, unless otherwise stated, defaults to left and scrolling defaults to auto. Frameborder defaults to 1 and marginwidth/marginheight defaults to about 5 each. The 'Longdesc' attribute is a decent supplement to the Title tag, which offers visually impaired users a description of the content. So, if I want to design an iframe with the name "MyIframe", 100% width, aligned in the center and with both marginwidth and marginheight set to 10, here's what the code looks like: <iframe src="url/to/document.html" width="100%"Sorry, your browser does not support iframes; try a browser that supports W3 standards. </iframe>Now that we know what an inline frame is, what it looks like and how to code it, which browsers support this element? We'll examine it below. Browser support for iframes • IE: IE appears to support the iframe since version 4 (Mac since version 3) Tutorial Pages: » Iframes: What are they, how to use them and which browsers support them » What are iframes? » Inline frame syntax » Where should iframes be used? |
|