Reputation: 1759
Lets say I have 2 tables wrapped inside a Div:
<div class = "main" id = "mainDiv">
<table id = "one">
1
</table>
<table id = "two">
2
</table>
</div>
How can I displays these two tables side by side with 5 px apart from each other? Is there something like "cellspacing" I can use but for tables?
Upvotes: 0
Views: 62
Reputation: 832
I would use css and you can make it so that it's responsive, Check out this code for 2 columns. In this code it is 2 equal width columns at 49.2%. If you want a different split change that.
/* SECTIONS */
.section {
clear: both;
padding: 0px;
margin: 0px;
}
/* COLUMN SETUP */
.col {
display: block;
float:left;
margin: 1% 0 1% 1.6%;
}
.col:first-child { margin-left: 0; }
/* GROUPING */
.group:before,
.group:after { content:""; display:table; }
.group:after { clear:both;}
.group { zoom:1; /* For IE 6/7 */ }
/* GRID OF TWO */
.span_2_of_2 {
width: 100%;
}
.span_1_of_2 {
width: 49.2%;
}
/* GO FULL WIDTH AT LESS THAN 480 PIXELS */
@media only screen and (max-width: 480px) {
.col {
margin: 1% 0 1% 0%;
}
}
@media only screen and (max-width: 480px) {
.span_2_of_2, .span_1_of_2 { width: 100%; }
}
<div class="section group">
<div class="col span_1_of_2">
This is column 1
</div>
<div class="col span_1_of_2">
This is column 2
</div>
</div>
Upvotes: 0
Reputation: 8537
Your structure is incorrect, it should be like this :
<div class = "main" id = "mainDiv">
<table id = "one">
<tr>
<td>1</td>
</tr>
</table>
<table id = "two">
<tr>
<td>2</td>
</tr>
</table>
</div>
And you could change the display:table;
of the table to display:inline-table;
to align them on one line.
Upvotes: 1