Red Cricket
Red Cricket

Reputation: 10460

How to make <button> fill a table cell <td>?

I have this HTML ...

<p align='center'>
<table width='100%'>
<tr>
<td align='center'><form><input type=submit value="click me"></form></td>
</tr>
</table>
</p>

... which results in a table and button that looks like this ...

button that does not fill table

... which is fine, but how would I make the button fill the entire cell?

Thanks!

Upvotes: 30

Views: 131874

Answers (1)

Solo
Solo

Reputation: 726

For starters:

<p align='center'>
<table width='100%'>
  <tr>
    <td align='center'>
      <form>
        <input type=submit value="click me" style="width:100%"> 
      </form>
    </td>
  </tr>
</table>
</p>

Note, if the width of the input button is 100%, you wont need the attribute "align='center'" anymore.

This would be the optimal solution:

<p align='center'>
<table width='100%'>
  <tr>
    <td>
      <form>
        <input type=submit value="click me" style="width:100%"> 
      </form>
    </td> 
  </tr>
</table>
</p>

Upvotes: 33

Related Questions