Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML table span entire width

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.

like image 321
T.T.T. Avatar asked Feb 11 '09 23:02

T.T.T.


People also ask

How do you span an entire table width?

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.

How do you make a full width in HTML?

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.

How do I fit an HTML table to fit the screen?

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> ...

How do you adjust the width of a table in HTML?

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.


2 Answers

Try (in your <head> section, or existing CSS definitions)...

<style>   body {     margin: 0;     padding: 0;   } </style> 
like image 58
Rog Avatar answered Oct 07 '22 15:10

Rog


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> 
like image 45
Kevin Tighe Avatar answered Oct 07 '22 14:10

Kevin Tighe