In my HTML document, I have a table with two columns and multiple rows. How can I increase the space in between the first and second column with css? I\'ve tried applying \"
Using border-collapse: separate; didn't work for me, because I only need a margin in-between the table cells not on the sides of the table.
I came up with the next solution:
-CSS
.tableDiv{
display: table;
}
.cellSeperator {
display: table-cell;
width: 20px;
}
.cell1 {
display: table-cell;
width: 200px;
}
.cell2 {
display: table-cell;
width: 50px;
}
-HTML
<div class="tableDiv">
<div class="cell1"></div>
<div class="cellSeperator"></div>
<div class="cell2"></div>
</div>
You can't single out individual columns in a cell in that manner. In my opinion, your best option is to add a style='padding-left:10px'
on the second column and apply the styles on an internal div or element. This way you can achieve the illusion of a greater space.
<!DOCTYPE html>
<html>
<head>
<style>
table{
border-spacing: 16px 4px;
}
td {
border: 1px solid black;
}
</style>
</head>
<body>
<table style="width:100%">
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
Using padding is not correct way of doing it, it may change the look but it is not what you wanted. This may solve your issue.
You can use both of them:
padding-right:10px;
padding-right:10%;
But it's better to use with %.