Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting table column width

I've got a simple table that is used for an inbox as follows:

<table border="1">         <tr>             <th>From</th>             <th>Subject</th>             <th>Date</th>         </tr> 

How do I set the width so the From and Date are 15% of the page width and the Subject is 70%. I also want the table to take up the whole page width.

like image 588
alamodey Avatar asked May 30 '09 02:05

alamodey


People also ask

How do you set column width in a table?

To change the width to a specific measurement, click a cell in the column that you want to resize. On the Layout tab, in the Cell Size group, click in the Table Column Width box, and then specify the options you want.

How do you fix a column width in a table?

The width of the columns i.e. td in a table can be fixed very easily. This can be done by adding the width attribute in the <td> tag. If the width is not specified, the width of the column changes according to the change in the content. The specifications of width for the columns can be in pixels, or percentage.

How do you set the width of a table?

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.


1 Answers

<table style="width: 100%">      <colgroup>         <col span="1" style="width: 15%;">         <col span="1" style="width: 70%;">         <col span="1" style="width: 15%;">      </colgroup>                        <!-- Put <thead>, <tbody>, and <tr>'s here! -->      <tbody>          <tr>              <td style="background-color: #777">15%</td>              <td style="background-color: #aaa">70%</td>              <td style="background-color: #777">15%</td>          </tr>      </tbody>  </table>
like image 105
Gordon Gustafson Avatar answered Sep 19 '22 01:09

Gordon Gustafson