I\'m trying to display tables next to each other horizontally, but this is what I\'m getting.
<!DOCTYPE html>
<html>
<body>
<table style="float: left; border-collapse:collapse; " border=\"1px;\" >
<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>
<table style="border-collapse:collapse; " border=\"1px;\">
<tr>
<td>Jill jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eveeve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>Johnjohj</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
This answer is taken from Chris Baker's answer of a duplicate question. Please up vote his answer.
One can use float: left
or display: inline-block
depending on content and space:
<table style="display: inline-block">
<table style="float: left">
This page is already setup with the HTML to try out and see how it looks in the browser: http://jsfiddle.net/SM769/
Documentation
display
on MDN - https://developer.mozilla.org/en/CSS:displayfloat
on MDN - https://developer.mozilla.org/en/CSS/floatExample
<table style="float: left">
<tr>
<td>..</td>
</tr>
</table>
<table style="float: left">
<tr>
<td>..</td>
</tr>
</table>
You have to apply a CSS rule to your tables in order to follow the normal document float which is:
table{ float:left; }
or
<table style="float: left;">.........</table>
PS: Just make sure that this tag selector block won't affect any other tables that you don't them to be so, otherwise you are recommended to use ID or class selectors.
try to add to your CSS file:
.table-wrapper {
display:inline-flex;
}
I have tried with display: inline-table
, with float: left
, and other stuff, but not a single one worked for me.
Adding display: table-cell;
to the tables may help.
http://www.quirksmode.org/css/display.html
And you may need to add wrapping div with display: table;
or add that property to some element depending on your page structure.
To show two tables side by side, you can add the below CSS:
table.table1, table.table2{
width:49.8%;
display: inline-table;
}