HTML table fit to screen: height, width

HTML table fit to screen: height, width

HTML tables can be puzzling for an HTML newbie. HTML alignment tricks are very simple once you get the hang of them. This article will show the code needed to make an HTML table fit the screen by setting the width.

To make an HTML table fit the screen:

  • Set the width to 100%, so that your code will look like this:
<table width="100%" border="0" cellspacing="0" cellpadding="0">  
<tr>  
      <td>My html table is set to fit the screen</td>  
</tr>  
</table>
  • This little block of code will set the width to fit the screen. If you want to align your content, you should use a nested table.

Alternatively, try this:

<style>
    body { margin:0;padding:0; }
</style>
<table width="100%" border="1">
    <tr>
        <td>Just a Test
        </td>
    </tr>
</table>

Other solutions

If you find that this still doesn't solve your issue:

  • Reduce the number of columns
  • Reduce the size of your margins
  • Reduce the font size
Any more programming questions, check out our forum!
Around the same subject