I have a table, first row is like
<tr> <th>1</th> <th>2</th> </tr>
I put a black background to "th". Now the 1 and 2 cells have some kind of border between/separating them... I had a look in source code and I think I found something:
border-collapse: separate; border-spacing: 2px;
This CSS code is listed in source code as "user agent stylesheettable" and I couldn't enable/disable it to test if this is the problem, but I tried and added the same code but with "none" and "0" parameters but it didn't help neither...
Can somebody help and guide me where is the border from please?
This is a Default behavior of the table cells that there is some space between their Borders. To remove this space we can use the CSS border-collapsing Property. This Property is used to set the borders of the cell present inside the table and tells whether these cells will share a common border or not.
Add: attributes cellpadding="0" , cellspacing="0" and border="0" to tables. style border-collapse: collapse; to tables. styles padding: 0; margin: 0; to each element.
The border-spacing value is also used along the outside edge of the table, where the distance between the table's border and the cells in the first/last column or row is the sum of the relevant (horizontal or vertical) border-spacing and the relevant (top, right, bottom, or left) padding on the table.
On a worksheet, select the cell or range of cells that you want to remove a border from. To cancel a selection of cells, click any cell on the worksheet. Click Home > the Borders arrow > Erase Border, and then select the cells with the border you want to erase.
Your table be like below by default and set the css rules on tables ID or Class
<table border="0" cellspacing="0" cellpadding="0"> <tr> <th>1</th> <th>2</th> </tr> </table>
css:
border-collapse: collapse;
Set a CSS rule on your table:
table { border-collapse: collapse; }
You can visit this jsFiddle example and switch the border-collapse property from collapse to separate to see how it changes the table's layout. The border-collapse property can only be collapse, separate, or inherited.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With