Consider:
<table border="1" width="100%" ID="Table2"> <tr> <td>100</td> </tr> </table>
This code still leaves an "inch" of space on both sides of the table. I am trying to get the table to span the entire width of the page.
You need to set the margin of the body to 0 for the table to stretch the full width. Alternatively, you can set the margin of the table to a negative number as well.
If you set the width to 100% on the body element you will have a full page width. This is essentially equivalent to not setting a width value and allowing the default. If you want to use the body element as a smaller container and let the HTML element fill the page, you could set a max-width value on the body.
To make an HTML table tit 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> ...
To set the table width in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <table> tag, with the CSS property width.
Try (in your <head> section, or existing CSS definitions)...
<style> body { margin: 0; padding: 0; } </style>
There might be a margin style that your table is inheriting. Try setting the margin of the table to 0:
<table border="1" width="100%" ID="Table2" style="margin: 0px;"> <tr> <td>100</td> </tr> </table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With