Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete border spacing in table

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?

like image 805
Alexandru Vlas Avatar asked Mar 30 '12 16:03

Alexandru Vlas


People also ask

How do I remove border-spacing in a table?

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.

How do I remove spaces from a table in CSS?

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.

What is border-spacing in table?

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.

How do you remove a border between cells?

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.


2 Answers

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; 
like image 137
w3uiguru Avatar answered Sep 22 '22 11:09

w3uiguru


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.

like image 29
j08691 Avatar answered Sep 21 '22 11:09

j08691