NAVIGATION:

 

SUPPORTERS:

FlashComponents
  Flash Templates
  Flash Gallery
  Flash Slideshow
  Flash Menu
  Flash Design
  Flash Video
  User Interface

 

FOLLOW:

RSS it down! Twitter it up! Facebook it like a fiend!

 

 

 

 

 
Removing the Margin
      by Kris Gosser AKA Kristopher : 9 February 2005

Introduction
Those margin issues just never seem to go away, now do they? There have been many recurring questions on the forum on how to get rid of the margin in the body, or how to make your Web site tight up to a corner. Well, in this tutorial, I'm going to explain how you get rid of that annoying margin, and then you'll be on your way!

The Problem

[ That little white-space between the viewport and my red square is annoying! ]

That was a screen shot of the little space we have between the edge of the screen and an element in your body. Now how do we fix that?

It's a lot easier than you think. Let's take a look at our code before the fix:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
div#main {
background: #FF3300;
width: 400px;
height: 400px;
}
</style>
</head>
 
<body>
<div id="main"></div>
</body>
</html>

Notice the div receiving the id "main." It's telling that div to be 400 pixels wide, 400 pixels tall, and also to have a red background.

The Fix
It's in between that tag called "style" that we are going to place our fix. Are you ready? Here's the code:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
div#main {
background: #FF3300;
width: 400px;
height: 400px;
}
 
body {
margin: 0px;
}
</style>
</head>
 
<body>
<div id="main"></div>
</body>
</html>

And here's a screen shot of the updated page:

[ Ahhh... That's better! ]

It worked! Notice that I declared the body has a margin of 0 (zero) pixels. This tells the browser that there shouldn't be any space between structural elements and the view screen.

Don't forget to visit our forums for more help. And feel free to PM (private message) me, Kristopher, via the forums. Have fun!

  Kris Gosser
www.krisgosser.com

 

 
SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components Flash effects. Art without coding.
Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Citrus Engine: Flash platformer and sidescrolling game engine
Learn how to advertise on kirupa.com

cdn
content delivery network (cdn)