build-website-header
spacer-image
 

 IFrames Explained

In Using IFrames we looked at the uses and problems of IFrames here we will look at the HTML behind IFrames in more detail.

The basic structure is:

<iframe src="examples/questions.htm"></iframe>

Where the only thing that needs to be specified is the page that should be displayed inside the frame. The result is shown below:

 

Now there are various things that we can control about the appearance of the frame by adding additional control attributes to the opening IFrame tag.

  • Width-width of frame in pixels or as percentage
  • Height-width of frame in pixels or as percentage
  • scrolling- allowed by default can be set to no, yes, auto
  • marginwidth=width in pixels between the frame and the left and right edges of the frame contents
  • marginheight=height in pixels between the frame and the top and bottom edges of the frame contents.
  • Align -align the frame to the page values are top, bottom, left, right, center
  • Name- the name of the frame used for targeting a frame.

Examples-1: no border, no scrolling, height 200 pixels, aligned to center

<p><iframe src="examples/questions.htm" frameborder=0 height="200" align="center" scrolling="no"></iframe></p>

The Name attribute is what lets you control the contents of the frame. Consider the following which has no source document as default, and so nothing is actually displayed inside the frame, but the frame has a name --- example1.

<p><iframe name="example1"></iframe></p>

Now to control what appears inside the frame we create a normal link to the web page questions.htm and tell it to display in the frame example1. The HTML is:

<a target="example1" href="examples/questions.htm">question</a>

And the same for the answer:

<a target="example1" href="examples/answers.htm">answer</a>

Click for the question and here for the answer.

 

Google
Web www.build-your-website.co.uk

Related Articles and Resources:



yahoo
Add to My Yahoo!
msn


Free Newsletter!


 

[Home page]  [About us] [Privacy Policy] [Contact Me]

IFrames Explained

spacer2-image