HTML Table Width

The width attribute specifies the width of a table or the width of a table cell. The width can be set either as an absolute value in pixels, or as in percentage (%). If the width attribute is not set, it will takes up the space of longest single word in each cell.

Table width in pixels

Table width in percentage (%)

The width value 100% indicates a width for the table that is the full width of the browser window.

html-table-width

HTML Source Code :

The above HTML code display two tables, one is 100 pixel width and another one is 100% width. First table is only 100 pixel width in any changes in browser window state, while other table will always stretch the full width of the window it is viewed in, that is the table automatically expands as the user changes the window size when you set width in % .

Cell Width or Column width

You can set the width of a table cell using width attribute.

The < td > width can be set either as an absolute value in pixels, or as in percentage (%).

table-cell-width.png

HTML Source Code :

Note: The width attribute of < td > is deprecated in HTML 4.01.

Table Height

Height attributes can be added to the < table > tag as well as the < td > tag.

The height attribute is not recognized by certain browsers, so be sure to do cross browser testing if you are relying on it.