Electric Type

Multimedia

About Us

News

Help

The IFrames Lowdown

Page 4 — Defining Borders and Margins

Floating frames have borders by default — meaning, if you don't instruct the browser to do otherwise, it will place a border around your frame. But you can alter border thickness by invoking the almighty frameborder attribute, which is defined in terms of pixels.

    <iframe width=150 height=200 src="blah.html" align=left frameborder=10> </iframe>

So this floating frame would have a border 10 pixels thick. But if you set the frameborder to, say, zero, your frame border becomes virtually invisible.

    <iframe width=150 height=200 src="blah.html" align=left frameborder=0> </iframe>

Think about that for a minute. If you have a frame with an invisible border smack dab in the middle of your content, how can you tell the difference between the content outside the frame and the content inside the frame? The answer is: You can't.

Unless you want to alienate your users or create an digital art installation liberated from all sensible convention, you need to find some way of addressing this problem. One way to differentiate the iframe content is to use smart design techniques. For example, a slightly different background color in your blah.html document will make the iframe stand out from the rest of the page. Or you could try using a different font color or size. You can also set the content apart by surrounding it with a distinct margin.

There are two kinds of margins you can set. The external margin is the space that surrounds the frame. It's set using the hspace and vspace attributes, which set the horizontal (left/right) and vertical (top/bottom) margins, respectively:

    <iframe width=150 height=200 src="blah.html" align=left frameborder=10 hspace=10 vspace=10> </iframe>

Internal margins are quite different because they're set, oddly enough, in the <body> tag of your document. Using the topmargin and the leftmargin attributes of the <body> tag, you can offset the internal margin of your frame window, like so:

    <body topmargin=10 leftmargin=5>

Starting from the top left, your document's content will now sit ten pixels down and five pixels over from the corner of the frame. Even if you don't plan to offset the internal margins, it's a good idea to define these attributes in the <body> tag anyway. You can do this by setting both values to zero. If you find your content is too long to fit comfortably within your frame, you can summon a scrollbar:

    <iframe width=150 height=200 src="blah.html" align=left frameborder=10 hspace=10 vspace=10 scrolling=yes> </iframe>

Of course, you can also turn off the scrollbar (by setting it to scrolling=no) or just let the browser decide for itself when the scrollbar is necessary (by setting it to scrolling=auto).

Now all you have to do is name the elements and make the thing actually work.

next page»


Dynamic HTML  

Frames  

HTML Basics  

Stylesheets  

Tables  

XML  

Javascript  

Database Connections  

Intro To Perl  

HTML 4.0  

User Blogs

Screen Shots

Latest Updates

Contact Us

Valid HTML 4.01!
Valid CSS!

Breadcrumb

© ElectricType
Maintained by My-Hosts.com
Site map | Copyright | Disclaimer
Privacy policy | Acceptable Use Policy
Legal information.