Forum Moderators: open

Message Too Old, No Replies

Table all the way to the top

I don't want that little gap at the top

         

steveweber123

2:13 pm on Oct 15, 2006 (gmt 0)

10+ Year Member



Hello,

Here is the top of the code for my page:

</head>

<body bgcolor="#000066">
<table width="740" border="0" align="center" cellpadding="0" cellspacing="7" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr valign="top">

The table BG is white, I would like it all the way to the top of the page, but there is a small row of blue background showing above the white table. I would just like the background to show on the sides of the table and not any above the table. Any help would be appreciated.

Thanks in advance,
Steve

penders

6:11 pm on Oct 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The body element (ie. the page) has its own padding/margins (depending on which browser you are using). To make your table appear at the very top, you need to set the top page margin/padding to 0 (zero).

Using an inline CSS style on your body tag:

<body bgcolor="#000066" style="margin-top:0;padding-top:0;">

Or, if you use an external stylesheet, you can set:

body { 
margin-top:0;
padding-top:0;
}

Tables, by default, don't have any margins, so that should sort it.

You might want to think about replacing some of your HTML attributes with CSS.

bgcolor
(which is now deprecated) can be replaced with the CSS equivalent of
background-color
. So, to repeat the previous example...

<body style="background-color:#000066; margin-top:0; padding-top:0;">

Or...

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

... would have the same effect.

Hope that helps.

steveweber123

2:35 am on Oct 25, 2006 (gmt 0)

10+ Year Member



Cool! That first line of code worked like a charm!

Thanks a lot! I really appreciate it!

Steve