H C H C - 1 year ago 71
HTML Question

Centering table on a page on bootstrap

I am trying to center a table using bootstrap.

Here is the html:

<div class="container-fluid">
<table id="total votes" class="table table-hover text-centered">
<th>Total votes</th>
<th> = </th>
<th>Voter A</th>
<th> + </th>
<th>Voter B</th>
<td>{{ total_votes }}</td>
<td> = </td>
<td>{{ total_voter_a }}</td>
<td> + </td>
<td>{{ total_voter_b }}</td>

However, no matter how I adjust the
, the table is still aligned to the left. I'm sure I am missing something simple. I also thought
would make the table span across the whole page.

here is the css:

.table th {
text-align: center;

.table {
border-radius: 5px;
width: 50%;
float: none;

Answer Source

You're missing the margin:auto

.table {
    border-radius: 5px;
    width: 50%;
    margin: 0px auto;
    float: none;


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download