PDA

View Full Version : [TUTORIAL] A Full Guide to the IFRAME Tag



timROGERS
12-11-2005, 08:17 AM
Using iFrames:

The iframe tag in HTML is a very diverse tag, which is particuarly useful when coding layouts. It is used exactly the same as most tags, with the following syntax:

<iframe attribute1="value" attribute2="value"></iframe>

With this tag, it is very important that you close the tag straight away, as placing anything between the <iframe> and the </iframe> may cause unwanted problems, putting the layout into jeopardy. Below is a section of all of the attributes of the iframe tag:

align
Allows you to specify the allignment of your iframe in relation to the text. The allowed values are left, right, top, middle and bottom.
eg. <iframe align="top"></iframe>

frameborder
Allows you to specify whether your iframe has a border. The allowed values are 0 and 1.
eg. <iframe frameborder="1"></iframe>

width and height
Sets the height/width of your iframe. May use any number, and can be measured in percentage or pixels.
eg. <iframe width="100%"></iframe> or <iframe height="500"></iframe>

marginheight and marginwidth
Specify the margins on the vertical and horizontal of the iframe, in pixels.
eg. <iframe marginwidth="20"></iframe>

name
Sets a name for the iframe, used with the target attibute in the "a" tag for hyperlinks.
eg. <iframe name="navigator"></iframe>

scrolling
Allows you to define whether there are scrollbars on the frame. Yes means there always will be, No means there never will be, and Auto means that they appear depending on the width and height of the source page of the iframe.
eg. <iframe scrolling="auto"></iframe>

src
Defines where the content of the iframe is displayed from. Use with a URL.
eg. <iframe src="navigator.php"></iframe>

So, having used all that, a sample iframe could be:

<iframe name="content" width="300" height="500" frameborder="1" align="middle" marginwidth="20" marginheight="10" src="content.php" scrolling="auto></iframe>

Sygon
12-11-2005, 08:36 AM
i already made 1 but we can bump it so it stays up

timROGERS
12-11-2005, 08:37 AM
Hopefully the noobs will stop spamming about it now, and if it gets stickied, we'll have an excuse to moan :P

monkey0660
12-11-2005, 10:59 AM
You forgot the div tag :)

timROGERS
12-11-2005, 11:04 AM
Thats mainly for the styling of it, if you'll write something about it, I'll add it though :)

Dan Williamson
12-11-2005, 11:42 AM
Lol, suppose it's a good tutorial for beginners.

Yet it doesn't stop people making threads "/

- Dan

timROGERS
12-11-2005, 11:43 AM
Yet it doesn't stop people making threads "/

- Dan

If only it did, it'd make life easier for all of the people that help others :D

Sygon
12-11-2005, 12:42 PM
Mine was better :P

Dan Williamson
12-11-2005, 01:01 PM
Mine was better :P

LOL.

- Dan

Want to hide these adverts? Register an account for free!