You have 40px of padding added to every
<td>, so when you add text to the element, the text is inserted and the cell expands to maintain the 40px of padding.
Try starting with this CSS instead, and then modify it from there:
border: 1px solid black;
I should mention though, a
<table> is primarily meant for storing data. It will work fine, but to be pedantic, a
<div> with display: inline-block might be more appropriate for a tic-tac-toe game board.