Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Firefox missing the border on some HTML tables

Tags:

I am using Firefox 3.5.7 and I have the same CSS used in multiple HTML tables, but there are some examples where parts of the borders are not shown.

What makes no sense to me is that the same CSS on the same page for another HTML table works fine. Also, the same page in Internet Explorer looks fine from a border point of view.

Here is an image with an example, as you can see in this case the bottom of the first table is missing a border.

enter image description here

Does anyone have a clue why this would happen here?

like image 612
leora Avatar asked Jan 14 '10 02:01

leora


People also ask

Why is my table border not showing in HTML?

If you've set the shorthand border property in CSS and the border is not showing, the most likely issue is that you did not define the border style. While the border-width and border-color property values can be omitted, the border-style property must be defined. Otherwise, it will not render.

How do I enable table Borders in HTML?

To create table border in HTML, the border attribute was used. But the introduction of HTML5, deprecated the border tag. Create table border using the CSS property border. Set table border as well as border for <th> and <td>.

How do you add a border to a table?

Click the table or select the cells where you want to add or change borders. On the Tables tab, under Draw Borders, on the Line Style pop-up menu, click the line style that you want. On the Tables tab, under Draw Borders, click Borders, and then click the borders that you want.


2 Answers

Maybe you've zoomed in/out a bit. This can happen either accidently or knowingly when you do Ctrl+Scrollwheel. Maybe it isn't completely resetted to zoom level zero. This mis-rendering behaviour is then recognizeable at some websites, also here at SO.

To fix this, just hit Ctrl+0 or do View > Zoom > Reset to reset the zoom level to default.

This is Firefox/Gecko bug 410959. This affects tables with border-collapse:collapse. It's from 2008 and there's no real progress on it, so you'll probably need to find a workaround. One way is using border-collapse:separate and fiddling with borders on a per-cell basis.

like image 93
BalusC Avatar answered Oct 21 '22 07:10

BalusC


I found a similar problem when zoomed out in Firefox on an application I am working on.

The main cause was having the CSS border-collapse property set to collapse.

Changing it to separate instead fixed the problem. However, that meant I did have to rethink the way borders are applied to various parts of the table, because otherwise your borders will appear to double in thickness. I ended up having to use jQuery to give a special "last" class to the last td or th in each tr, and to the last tr in the table. My query was something like:

$('table tr > th:last-child, table > tbody > tr > td:last-child, table > tbody > tr:last-child').addClass('last'); 

My CSS rules were similar that:

table {     border-collapse: separate !important; }  table tr, table th, table td {     border-right-width: 0;     border-bottom-width: 0;     border-left: 1px solid black;     border-top: 1px solid black; }  table td.last, table th.last  {     border-right: 1px solid black; }  table tr.last td {     border-bottom: 1px solid black; }  table {     border: 0; } 

I did end up using browser targeting so that I only applied these rules to Firefox users, but it may work for all browsers, I haven't tested.

like image 29
GregL Avatar answered Oct 21 '22 06:10

GregL