View Full Version : <img height="0">

12-15-2002, 06:23 AM
Hello, I am using <img> tags with 0 height and a set width without a src to make sure that certain things are big enough when I use %'s for widths. The problem is when I do this, you can't see the img, but it takes up too much vertical space. Can anyone tell me what i could do about this? Thanks a lot.

12-15-2002, 06:39 AM
well, you arent going to see the image if the height is 0 (if that was one of the problems). i dont think it should show any vertical space, but if you post the html i could look at it and it would be easier to solve your problem.

12-15-2002, 08:00 PM
Here is the code that I am currently using:

<img width="800" class="spacer"/>
<table class="header" rows="2" cols="2" cellspacing="0" width="100%" cellpadding="0" height="120">

The declaration for the spacer class is:

img.spacer {height: 0px; border: 0px 0px 0px 0px; margin: 0px;}

Any ideas? Thanks a lot.

12-15-2002, 08:19 PM
well, i know if you dont define the height when using a defined width, that it assumes the same dimension for the height. So, if you define the table's height as something other than 0, it will be that height.

<img width="800" class="spacer" height="20"/>
<table class="header" rows="2" cols="2" cellspacing="0" width="100%" cellpadding="0" height="theheightyouwant">

12-16-2002, 02:51 AM
So you are saying that the style defined is not working?

12-16-2002, 03:11 PM
why not place the width and height in the css
also, you have the border specifying every side, if its all the same why not just use shorthand like you did with the margin?

12-16-2002, 03:24 PM
height and width are deprecated attributes of the table tag - should only appear in <td> tags.

any element (even a 0px high image) is assumed to be rendered in a line conforming to the parental font specs.

.spacer {font-size:1px}

should help assure that any line break below the image (new tr of br) doesn't cause as much vertical space.

12-17-2002, 02:57 AM
Ok, that didn't work and I am refering to the <img>, not to the table. Any other ideas.

12-17-2002, 05:05 AM
first off use a 1x1 invisible pic as your source. As mentioned above: A 0 Pixel height means it will do nothing at all.

12-22-2002, 07:16 AM
Ok, I got it to work in IE with the following:

<img width="800" height="1" src="transparent.gif"/><br style="line-height: 1px; font-size: 1px;"/>

But it still doesn't work in Netscape 7. Any ideas?
Thanks a lot.

12-22-2002, 07:38 AM
Any img with a 1 px size will be frowned upon in search engines. The reason is that ppl stuff alt tags in there...Sorry...Better figure out an better way unless you don't care about search engines. :o

12-22-2002, 05:05 PM
If it will be frowned upon than do you have any other way to accomplish the same thing without an image? I want to make the table with my content 100%, but I never want it to be smaller than 800px wide. Thanks a lot.