Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table tag / browser window margin? 2

Status
Not open for further replies.

CBrownAtWork

Technical User
Sep 27, 2004
7
US
Hi

I'm new to HTML & CSS and trying to rebuild an existing table-based layout with absolute positioning. Does the table tag add margins between itself and the browser window? It seems like it does -- around 15 pixels or so?

Code:
<html>
<body>
<!--original table structure-->
<table border='0' cellpadding='0' cellspacing='0' width='760'>
<tr>
<td height='34' colspan='4'>gif</td>
</tr>
<tr>
<td width='42'>gif</td>
<td width='132'><font color='blue'>gif</td>
<td width='443'>gif</td>
<td width='143'><font color='blue'>gif</td>
</tr>
</table>
<!--new layout-->
<div style='position: absolute; left: 42px; top: 34px; color: red'>gif</div>
<div style='position: absolute; left: 617px; top: 34px; color: red'>gif</div>
</body>
</html>

Does anyone know how big this margin actually is so I can compensate for it? Thank you!

-- Chris
 
CSS is your friend.

Try this:

Code:
<html>
[red]
<head>

<style type='text/css'>

body {
   margin: 0;
}

</style>

</head>
[/red]
<body>
<!--original table structure-->
<table border='0' cellpadding='0' cellspacing='0' width='760'>
<tr>
<td height='34' colspan='4'>gif</td>
</tr>
<tr>
<td width='42'>gif</td>
<td width='132'><font color='blue'>gif</td>
<td width='443'>gif</td>
<td width='143'><font color='blue'>gif</td>
</tr>
</table>
<!--new layout-->
<div style='position: absolute; left: 42px; top: 34px; color: red'>gif</div>
<div style='position: absolute; left: 617px; top: 34px; color: red'>gif</div>
</body>
</html>

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
The body intately has a margin. If you do not want any add:

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

[conehead]
 
If you're doing it ConeHead's way, don't forget about rightmargin and bottommargin for NetSlop.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
With a little experimenting I think it looks like the body tag adds 10px to the left and 15px to the top, at least in IE6.

I'm trying to prove to the developers that I can duplicate their table layouts with CSS, only cleaner. That's why I have to match my layout with theirs exactly.

Thanks for the help!
 
If they still don't believe you, tell them to go to GOOGLE and type CSS for a search word.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
And use as much relative positioning as possible. Absolute positioning is best avoided when not neccessary.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top