HTML Query

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi, I'm pretty good normally with HTML, but for some reason I'm blind as to
why the following code doesn't work:

<body topmargin=0 marginheight=0 leftmargin=0>
<table cellpadding=0 cellspacing=0 width=100% border=0>
 <tr height=2>
           <td bgcolor=black width=100% height=2>
            <td bgcolor=#666666 height=2>
                 <img src="spacer.gif" width=190 height=2>

I simply want a 2 pixel high bar across the screen with the last 190 pixels
being grey and the rest black.  spacer.gif is a 1x1 pixel transparent gif.

Instead of being 2 pixels high, it is (I think) 18 pixels high, and I can't
seem to find any way of making it smaller.


Re: HTML Query

Quoted text here. Click to load it

I can't vouch for other browsers, you'd have to try it, but in IE6 it works
to keep each cell on one line with no gaps like so:

           <td bgcolor=black width=100% height=2></td>
           <td bgcolor=#666666 height=2><img src="spacer.gif" width=190

because line breaks and returns are often interpreted as a single space
character (intented so that you can put line breaks in a paragraph of text
to keep your source looking neat), which will try to fit in the table thus
stretching it vertically.

Nick Howes

Re: HTML Query says...
Quoted text here. Click to load it

I agree with the other poster - keep the <td> and </td> on the same line
with no gaps. A new line in HTML is treated as a space, so you are
forcing the td height to be at least as tall as a character in the font


Remove NOT from email address to reply. AntiSpam in action.

Re: HTML Query

Quoted text here. Click to load it

[snip code]

Good advice on the whitespace so far. You can also lose the height
attribute for your table row as it doesn't exist.

It is also recommended that attributes are delimited using quotation


Re: HTML Query

Quoted text here. Click to load it

Why do you have cell #1 width set to 100%??
You declared the base of the table width to 100% in the <table> tag.
So by declaring the #1 cell also to 100%, cell #2 has nothing to use.
That could be what's driving the spacer height up to 18 pixels.
It has nowhere to go.
As a test, change the cell#1 width to 50% and see what happens.

Site Timeline