Jump to content

[SOLVED] Basic CSS: Body Margins (stuck with a 1px margin somehow)


webmaster1

Recommended Posts

Hi All,

 

When I use regular html I can achieve a margin free layout:

 

<body TOPMARGIN="0" LEFTMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0" >

 

When I try it with CSS my table is pushed down by 1px from the top of the page:

 

body{
margin: 0px 0px 0px 0px;
}

table.gtop{
width:1025px;
height:125px;
margin-left:auto;
margin-right:auto;
border:0px;
border-style:none;
padding:0px;
}

 

Can anybody spot what's missing or faulty?

Link to comment
Share on other sites

Here's the relevant html:

 

<table class="gtop">
<tr>
	<td width="460" height="125" bgcolor="#000066">
		<a href="index.html"><img width="460" height="125" src="images/general_logo.jpg" border="0"></a>
	</td>
	<td width="565" height="125" bgcolor="#0066CC">		
	</td>
</tr>
</table>

 

And here's the corrosponding css:

 

body {
padding:0;
margin: 0;
background-color:#990033;
}

table.gtop{
width:1025px;
height:125px;
margin: 0 auto;
border: none;
padding:0;
}

 

Here's an image:

 

error.JPG

 

I just added the bg colour to make the discrepancy more apparent. Notice the 1px at the top and bottom of the table and the also in between the td cells.

 

Also the logo image should overlay its td cell exactly since they are the same size but you'll notice a navy border thats larger at the bottom.

 

I'll be rigorously checking the css for cross browser issues as soon as I can get it functioning on IE.

 

Link to comment
Share on other sites

Yay! Solved with this minor addition:

 

border-collapse:collapse

 

I am absolutley dreading the road ahead in making my CSS cross browser compatable. Its a nightmare for forms. To see what I mean you can check out a quick page I threw up at www.joycepromotions.com Viewing it in Safari, Firefox and Chrome will distort my intended layout, particularily the text area  :-[

 

Anyhow, one step at a time. The issue at hand is solved.

 

Sniperscope: Here's a good starting point for uniform cross browser CSS: http://www.designvitality.com/blog/2007/10/designing-for-every-browser-how-to-make-your-site-fully-cross-browser-compatible/. I haven't looked into it great deal yet.

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.