You could try using the <col> tag manage table styling for all rows but you will need to set the table-layout:fixed style on the <table> or the tables css class and set the overflow style for the cells

http://www.w3schools.com/TAGS/tag_col.asp

<table class="fixed">
    <col width="20px" />
    <col width="30px" />
    <col width="40px" />
    <tr>
        <td>text</td>
        <td>text</td>
        <td>text</td>
    </tr>
</table>

and this be your CSS

table.fixed { table-layout:fixed; }
table.fixed td { overflow: hidden; }
Answer from hunter on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ html โ€บ html_table_sizes.asp
HTML Table Sizes
Note: Using a percentage as the size unit for a width means how wide will this element be compared to its parent element, which in this case is the <body> element. To set the size of a specific column, add the style attribute on a <th> or <td> element: ... <table style="width:100%"> <tr> <th style="width:70%">Firstname</th> <th>Lastname</th> <th>Age</th> </tr> <tr> <td>Jill</td> <td>Smith</td> <td>50</td> </tr> <tr> <td>Eve</td> <td>Jackson</td> <td>94</td> </tr> </table> Try it Yourself ยป
๐ŸŒ
W3Schools
w3schools.com โ€บ css โ€บ css_table_size.asp
CSS Table Size (Width and Height)
The CSS width property is used to set the width of a table. ... The CSS height property is used to set the height of a table. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: ...
People also ask

How do I make an HTML table responsive?
To make an HTML table responsive, use percentage-based widths, apply CSS media queries to adjust the layout for smaller screens, and enable overflow for horizontal scrolling when necessary.
๐ŸŒ
dhiwise.com
dhiwise.com โ€บ post โ€บ html-table-width-best-practices-for-a-modern-web-design
How to Set HTML Table Width For Responsive UI: Detailed Guide
What is the role of CSS in responsive table design?
CSS plays a crucial role in responsive table design by allowing you to control widths, apply media queries, and manage layout changes like hiding columns or stacking rows for smaller screens.
๐ŸŒ
dhiwise.com
dhiwise.com โ€บ post โ€บ html-table-width-best-practices-for-a-modern-web-design
How to Set HTML Table Width For Responsive UI: Detailed Guide
Should I use fixed or percentage-based widths for HTML tables?
Itโ€™s best to use percentage-based widths for HTML tables, as they allow the table to adapt to various screen sizes, providing a more responsive and flexible design.
๐ŸŒ
dhiwise.com
dhiwise.com โ€บ post โ€บ html-table-width-best-practices-for-a-modern-web-design
How to Set HTML Table Width For Responsive UI: Detailed Guide
๐ŸŒ
DhiWise
dhiwise.com โ€บ post โ€บ html-table-width-best-practices-for-a-modern-web-design
How to Set HTML Table Width For Responsive UI: Detailed Guide
June 17, 2025 - The Basics of HTML Table Width For Responsive LayoutsUsing CSS for Responsive Table WidthsFixed vs.
Top answer
1 of 7
286

You could try using the <col> tag manage table styling for all rows but you will need to set the table-layout:fixed style on the <table> or the tables css class and set the overflow style for the cells

http://www.w3schools.com/TAGS/tag_col.asp

<table class="fixed">
    <col width="20px" />
    <col width="30px" />
    <col width="40px" />
    <tr>
        <td>text</td>
        <td>text</td>
        <td>text</td>
    </tr>
</table>

and this be your CSS

table.fixed { table-layout:fixed; }
table.fixed td { overflow: hidden; }
2 of 7
117

Now in HTML5/CSS3 we have better solution for the problem. In my opinion this purely CSS solution is recommended:

table.fixed {table-layout:fixed; width:90px;}/*Setting the table width is important!*/
table.fixed td {overflow:hidden;}/*Hide text outside the cell.*/
table.fixed td:nth-of-type(1) {width:20px;}/*Setting the width of column 1.*/
table.fixed td:nth-of-type(2) {width:30px;}/*Setting the width of column 2.*/
table.fixed td:nth-of-type(3) {width:40px;}/*Setting the width of column 3.*/
<table class="fixed">
    <tr>
        <td>Veryverylongtext</td>
        <td>Actuallythistextismuchlongeeeeeer</td>
        <td>We should use spaces tooooooooooooo</td>
    </tr>
</table>

You need to set the table's width even in haunter's solution. Otherwise it doesn't work.
Also a new CSS3 feature that vsync suggested is: word-break:break-all;. This will break the words without spaces in them to multiple lines too. Just modify the code like this:

table.fixed { table-layout:fixed; width:90px; word-break:break-all;}

Final result

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ html โ€บ html-table-width-attribute
HTML <table> width Attribute - GeeksforGeeks
July 11, 2025 - The HTML <table> element's width attribute specifies the width of the table. It can accept values in pixels or percentages.
๐ŸŒ
SitePoint
sitepoint.com โ€บ html hub โ€บ table sizes
HTML Table Sizes | SitePoint โ€” SitePoint
Set the table width to 100% for mobile and specify a fixed width (e.g., 600px) for larger screens. ... <style> table { width: 100%; border: 1px solid black; } @media (min-width: 600px) { table { width: 600px; } } </style>
๐ŸŒ
HTML.com
html.com โ€บ attributes โ€บ td-width
Stop Using To Set Table Width In HTML: Here's Why ยป
January 24, 2020 - This attribute has been deprecated. Use CSS to control layout of data cells in HTML tables. The width attribute, now deprecated, was once the correct way to adjust the width of a tableโ€™s columns. By default, a browser will adjust table columns to fit the contents of the table.
Find elsewhere
๐ŸŒ
Scaler
scaler.com โ€บ topics โ€บ html-table-width
How to Set HTML Table Width? - Scaler Topics
November 2, 2022 - Find out what is html table width. The HTML table width attribute is used to specify the width of a table or the width of a table cell. The width can be absolute as in pixels or relative as in percentage (%).
๐ŸŒ
Ironspider
ironspider.ca โ€บ tables โ€บ tablecells3.htm
Table Cells - Width and Height
Web browsers will automatically set the dimensions of the rows and columns in your web page table according to how much content your table cells contain. Since cells are displayed in a grid-like pattern then the cell containing the most content will typically set the width and height of all cells adjacent to it and hence establish the width and height of related rows and columns in your table.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ html โ€บ html-table-sizes
HTML Table Sizes - GeeksforGeeks
August 5, 2025 - Set a width to 50% to a particular column. Example: Implementation to show how to set HTML Table Sizes using width 50% to the <th>.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ HTML โ€บ Reference โ€บ Elements โ€บ table
<table>: The Table element - HTML | MDN
vertical-align: CSS property to vertically align table cell content ยท width: CSS property to control the width of the table
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-set-table-width-in-html
How to set table width in HTML?
The attribute is used within the HTML <table> tag, with the CSS property width to set table width.
๐ŸŒ
Medium
codewithsuraj.medium.com โ€บ controlling-table-sizes-in-html5-a-comprehensive-guide-with-examples-ff1202cf6d56
Controlling Table Sizes in HTML5: A Comprehensive Guide with Examples | by Code with Suraj | Medium
October 23, 2023 - HTML5 tables consist of several ... using HTML attributes and CSS properties. Width: The width attribute in the <table> element sets the width of the entire table....
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ CSS โ€บ Reference โ€บ Properties โ€บ table-layout
table-layout - CSS | MDN
When using this keyword, the table's width needs to be specified explicitly using the width property. If the value of the width property is set to auto or is not specified, the browser uses the automatic table layout algorithm, in which case the fixed value has no effect.
๐ŸŒ
Result University
resultuniversity.com โ€บ html โ€บ html-table-width-height
HTML Table Size: Width & Height of Columns & Rows
Let's see an example where we have set the width of the first table to 200px and the width of the second table to 100%. Click on 'result on editor' to view the output of the code. ... <!DOCTYPE html> <html> <head> <title>Table Width Example</title> <style> table, td, th { border:2px solid black; border-collapse: collapse; } </style> <head> </head> <body> <h1>Table Width Example</h1> <table style="width:200px;"> <tr> <th>No</th> <th>Country</th> <th>Capital</th> </tr> <tr> <td>1</td> <td>India</td> <td>Delhi</td> </tr> <tr> <td>2</td> <td>Australia</td> <td>Canberra</td> </tr> <tr> <td>3</td> <
๐ŸŒ
Ironspider
ironspider.ca โ€บ tables โ€บ widthalign.htm
Table Width and Alignment
By default, web browsers will define the width of a table as the minimum width required to hold the table's contents. You can, however, apply the width attribute to the table element to explicitly set the width of your table. Also, providing the table does not fill or exceed the width of the ...
๐ŸŒ
W3C
w3.org โ€บ MarkUp โ€บ html3 โ€บ tables.html
Tables
The default sizing algorithm requires two passes through the table data. In the first pass, word wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. The maximum width is given by the widest line. As word wrap has been disabled, paragraphs are treated as long lines unless broken by <BR> elements.
๐ŸŒ
Corelangs
corelangs.org โ€บ home โ€บ html โ€บ html tables โ€บ mastering html table width: a guide to perfectly sized columns
HTML Table Column Width: Essential Tips for Perfect Columns
May 21, 2024 - In this example, the width attribute is set to 500, indicating a width of 500 pixels for the table. However, using inline attributes like this is considered outdated and less flexible compared to CSS. Cascading Style Sheets (CSS) offer a more versatile and modern approach to styling HTML elements, including tables.