Attributes of IFrame Tag
Src
Src indicates the URL of the document that is to go within the frame.
Example |
<iframe src=”hello.html”> |
If you can see this then your browser does not understand iframes. |
</iframe> |
| |
Height and Width
Height and Width attribute set the dimension of the inline frame.
Example |
<iframe src=”hello.html” width=450 height=100> |
If you can see this then your browser does not understand iframes. |
</iframe> |
| |
Name
Name indicates the name of the inline frame. It works in the same way as in the frame tag.
Example |
<iframe src=”tables.html” width=450 height=100 name=”tables”> |
|
</iframe> |
| |
Frameborder
Frameborder indicates whether the inline frame should have a border around it. The default value is 1 which sets a border. The value is set to 0 when a border is not required.
Example |
<iframe src=”tables.html” width=450 height=100
name=”tables” frameborder=0> |
|
</iframe> |
| |
Marginwidth
Marginwidth sets the internal left and right margins of the internal frame. It works similarly as in the frame tag.
Example |
<iframe src=”tables.html” width=450 height=100
name=”tables” frameborder=0 marginwidth=2> |
|
</iframe> |
| |
Marginheight
Marginheight sets the internal top and bottom margins of an inline frame. It works in the similar way as in the frame tag.
Example |
<iframe src=”tables.html” width=450 height=100
name=”tables” frameborder=0 marginheight=2> |
|
</iframe> |
| |
Scrolling
Scrolling indicates whether there should be scrollbars in the frame. It has three values- yes, no and auto. Yes means there will be a scrollbar even if it is not required. No means there will not be a scrollbar even if it is required. Auto is the default value that means there will be scroll bars as and when required.
Example |
<iframe src=”tables.html” width=450 height=100
name=”tables” scrolling=yes> |
|
</iframe>
<iframe src=”hello.html” width=300 height=150
Name=”hello” scrolling=no >
</iframe> |
| |
Align
Align offers an array of alignment options like the image tag. However, for the <iframe> tag there are only three options. These are left, right and not align at all.
Left and right indicate that the frame should align to the left or right side of the page and the text should flow around it. The no align attribute indicates that the frame is inline with the text.
Example |
<iframe src=”tables.html” width=450 height=100
name=”tables” scrolling=yes align=left> |
|
</iframe>
<iframe src=”hello.html” width=300 height=150
Name=”hello” scrolling=no align=right>
</iframe> |
| |
Vspace and Hspace
Vspace sets the vertical distance between the text and the inline frame. Hspace sets the horizontal distance between the text and the inline frame. These attributes are most commonly used with the align attribute.
Example |
<iframe src=”tables.html” width=450 height=100
name=”tables” hspace=5 vspace=5> |
|
</iframe> |
| |
The following example illustrates a web page using frames:
|