Clip Art Images and Animation Downloads from Graphics Factory
JOIN TODAY LEARN MORE USER REVIEWS USAGE RIGHTS HELPSIGN-IN
You are here: Home > Support > Techniques for eliminating a document's default margins

Setting Your Page Margins

Since the inception of the very first HTML document, margins existed that surrounded the document, like in the case with this document. The margins are there to act as a cushion between the edges of the browser and the contents of the page, so it's easier to read this content.

As good as margins are, wouldn't it be nice to be able to eliminate them in some cases, where the design of the page calls for their termination? While most developers think it's not possible to "flush out" the default margins of a HTML document, it actually is, although only possible in IE 3+, and NS 4+. In this tutorial, I'll show you how.

-Eliminating the document margin in IE 3+

To get rid of the document margin in IE 3 and above, so content presses right against the edges of the browser, use the IE exclusive "leftmargin" and "topmargin" attributes:

<body leftmargin="0" topmargin=0">

It's as simple as that!

-Eliminating the document margin in NS 4+

To get rid of the document margin in NS 4 and above, use the NS 4 exclusive "marginwidth" and "marginheight" attributes instead:

<body marginwidth="0" marginheight=0">

-Putting it all together

By putting the two techniques together, we can create a document that flushes out its' margins in both IE 3+ and NS 4+:

<body leftmargin="0" topmargin=0" marginwidth="0" marginheight=0">

Try out the above declaration on your page, and you'll see what I mean.

-----------------------------
This tutorial is written and contributed to Clip Art, Inc. by George Chiang. He mantains Website Abstraction (http://wsabstract.com), a site dedicated to JavaScript programming and script help.



Signin


  • Unlimited Downloads
  • No Per-Image Fees
  • Instant Access
  • Royalty-Free Usage rights


1 Year access $49.95 Join Now


Join Today - Sign-In - Affiliate Program - About Us - Privacy Statement - Newest Images - Site Map - RSS - Blog

GraphicsFactory.com is Celebrating 11 Years Online!
Copyright © 1997-2008 GraphicsFactory.com. All Rights Reserved.