-1

I want my table to be deadsmack in the middle of the page but it keeps sticking to the side. Firstly I tried using floats but it wouldnt work. Now I'm trying to center my table with images using margins but I can't seem to get it to work. Here is my code:

<div class="table_images">
          <table>
              <tr>
                  <td><img src="image/copyright.png" alt="copyright" width="70" height="70" align="left"></td>
                  <td><img src="image/copyright.png" alt="copyright" width="70" height="70" align="left"></td>
              </tr>
              <tr>
                  <td><img src="image/copyright.png" alt="copyright" width="70" height="70" align="left"></td>
                  <td><img src="image/copyright.png" alt="copyright" width="70" height="70" align="left"></td>
              </tr>
              <tr>
                  <td><img src="image/copyright.png" alt="copyright" width="70" height="70" align="left"></td>
                  <td><img src="image/copyright.png" alt="copyright" width="70" height="70" align="left"></td>
              </tr>

          </table>

      </div>

and my CSS code

.table_images{
      margin-right: auto;
      margin-left: auto;
  }

any help would be appreciated.

mistersenpai
  • 59
  • 1
  • 8
  • The code you have provided makes me wonder if you are using a table when you should in fact be using one. Tables should be used when the relationships of things only makes sense when arranged in columns and rows (or if at least it merely makes *more* sense, without strictly requiring it). – Jan Kyu Peblik Jun 03 '20 at 23:11
  • the margin trick applyied to the table not the div – Temani Afif Jun 03 '20 at 23:12

1 Answers1

2

Apply the margins to the table instead, like so:

.table_images table {
      margin-right: auto;
      margin-left: auto;
}

That said, using tables for this scenario is probably not the way to go, semantically speaking.

HaukurHaf
  • 13,522
  • 5
  • 44
  • 59