views:

58

answers:

4

I have a <td> that is just about empty since it only contains an &nbsp;. The height I'm trying to enforce is 110 pixels, but for some reason the table cell is rendered with a height of 182.317 pixels. Why?

There are a few things I already checked:

  • The font-size that applies to the non-breaking space isn't set to something that cannot fit into the table cell.
  • There's no table cell on the same row that needs to stretch in order to fit its content into that cell.
  • There's no piece of CSS code that overwrites the height I want with the inexplicable value of 182.317 pixels.

What else could be the culprit? The cell renders with the expected height in Chrome, but it messes up in Firefox 3.6. The rendering mode is XHTML 1.0 Strict (yes, I did validate).

Update: you can view and analyze the page at http://labs.pieterdedecker.be/vspwpg/. The <td> I'm talking about is leftbartop.

A: 

Do you have a line-height set for the table cells or somewhere in the cascade that affects it directly?

Robusto
I haven't set a value for `line-height` that affects the table. However, I can confirm that Firebug reports 18px inside the cell. The only place where I used `line-height` affects `ul#menu > li > ul li`.
Pieter
A: 

does it work if you say

{height:95px !important;}

Perhaps you have set padding or something like that that is affecting the td

Vernon
Alas, adding `!important` doesn't work. Will look into padding/margin.
Pieter
Update: removing all padding/margin in the table and its cells doesn't fix the problem.
Pieter
+2  A: 

Use Firebug and take a look at the cell via the element inspector. On the bottom right using Firebug, look at the style. Scroll down until you see an area where you are setting the height of the cell. If you still can't find it, try right click in the style area and adding it in the top most style selector.

Eventually you'll either find the culprit that is overwriting your styling, or you'll be able to find a class that you can use to overwrite the style that is being applied. You can also use Google Chrome's developer tools to do the same (just right click anywhere on the page and "inspect element" to bring them up).

Organiccat
+1. While this isn't technically an answer, it's the best method of finding one with the information given. I'd recommend this as well.
tjko
I used Firebug to find the computed height (as shown in my question), so I'm well aware that these tools can be very helpful indeed. Both Chrome's element inspector and Firebug often help me iron out problems with my CSS, but this time they're not enough.
Pieter
A: 

You don't say which of the columns in the table has the issue. But, I suspect that it is:

<td id="bottombar2" colspan="2"></td>

The attribute colspan="2" tells the cell to be two rows high. Your rows are 95px, that would make it 190px high (roughly the height you are seeing).

Each row in your table specifies a different number of columns 5, 1 and 3. This might explain why the table is rendered differently by different browsers.

Philip Smith
`td#bottombar2` is rendered fine, it's `td#leftbartop` I'm having problems with. (I should have clarified, I know.) Also, I thought that `colspan="2"` tells the cell to be two cells wide instead of two cells high. Or am I mistaken?
Pieter
My bad. I have confused rowspan and colspan. In which case row one has three columns as does row two, but row three has four columns. I don't get why leftbartop is a problem.
Philip Smith
D'oh. I don't know how it happened, but when I was posting the table skeleton I somehow forgot the fourth column on the first row, which is `<td id="sidebar" rowspan="2"></td>`. So every row normally does contain four columns, but that's not where the problem lies. You can view the site here: http://labs.pieterdedecker.be/vspwpg/
Pieter
The matter can be improved by increasing the height of `lefbtar`. It seems that your layout needs the two left hand cells to equal the height of the other columns. I have no idea why.
Philip Smith
`leftbar` isn't set to a fixed height. It stretches when necessary. So if I set `leftbartop` to a fixed height, `leftbar` takes the remaining space. Am I missing something?
Pieter
So you haven't tried it then? Why did I bother? You just have to try it to see that it has an effect. I said I don't know why, because it is not intuitive.
Philip Smith
Sorry- I tried it and you're absolutely right. But there's even better news: while I was trying this, I discovered that I had set both cells to a fixed height, so Firefox couldn't possibly respect both heights at the same time. The mistakes I make are so lame sometimes. :[ Anyway, thanks Philip and everyone else who contributed!
Pieter