Borders not shown in Firefox with border-collapse on table, position: relative on tbody, or background-color on cell

Peter picture Peter · Sep 22, 2011 · Viewed 44.3k times · Source

Consider the following HTML:

Notice that the last cell has a left and a right border in its inline style. You (or at least I) would expect this to be visible. In IE, this is the case. But in Firefox (6), this is not. You can solve this by:

  • Removing position relative on div.datagrid table tbody in the CSS
  • Changing div.datagrid table tbody to div.datagrid table in the CSS
  • Removing the background-color on table.data td.priceCell in the CSS
  • Removing the border-collapse on div.datagrid table in the CSS

This is a simplified version of our code; we also solved it (by choosing option 2). But what I'm wondering about is:

  • Is this a bug in Firefox?
  • Is this a bug in IE?

And especially: what is the reason Firefox wouldn't show the borders when the CSS is as it is?

Answer

medoingthings picture medoingthings · May 2, 2013

Just ran into this issue and came to a css only solution: just add background-clip: padding-box to your td element.

See this article for more information: https://developer.mozilla.org/en-US/docs/CSS/background-clip