30

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!

1

1 Answer 1

33

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>
2
  • 2
    Thanks. Would I need height:100% also ? if so would I use this: style="width:100%;height:100%" ? Commented Sep 11, 2012 at 4:58
  • You would only need to do that if the height of your <td> element is greater than the height of the <input> element. You could definately do that.
    – Solo
    Commented Sep 11, 2012 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.