1

I'm using BlueGriffon and reading the following links:

Center-align a HTML table

Center a table

CSS: Centered tables

about how to center a table using CSS, as align has been deprecated. However, none of them are working, the code suggested in the 3 links to center a table looks like this:

.centered-table {
     margin-left: auto; 
     margin-right: auto%; 
}

My code:

CSS:

.maintbl {
  margin-left: auto; 
  margin-right: auto%; 
}

HTML:

 <table class="maintbl" id="tblMain">
  <tbody>
    <tr>
      <td>Hello world<br>
      </td>
    </tr>
  </tbody>
</table>

Instead of centering, it appears on the right side. I copied the code from the last link directly into the editor, and the result was the same. What wrong and how do I fix it?

Community
  • 1
  • 1

1 Answers1

0

I think its better practice for table center. just use css on the table tag

example.

 table {
        width: 60%;
        margin: 0 auto;
    }
Musarrof
  • 39
  • 9