HTML Table Column Width

To specify width to a column, set the CSS width property of column heading th or any of the cell td in the respective column.

Refer CSS width property tutorial to know about valid width values and examples.

By default, the content decides the width of the table. If the content is larger than the width of its parent, then the content is wrapped in more than one line.

Examples

Column Width of 200px

In the following example, we specify a width of 200px for the first column. We have provided the width as inline-css.

index.html

Column Width of 10em

In the following example, we specify a width of 10em for the first column, and a width of 7em for the second column. We have provided the width as inline-css.

index.html

Column Width via Cell (td)

Not only using th, but we can also set the column width by specifying width for any cell (td tag) in that column.

index.html

ADVERTISEMENT

Conclusion

In this HTML Tutorial, we learned how to set a specific width for column of HTML table, with examples.