HTML <td> width Attribute Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The HTML <td> width attribute was traditionally used to specify the width of a table cell. If this attribute is not set, the cell automatically adjusts its width based on the content it contains. This attribute provides flexibility as it accepts values in both pixels and percentages, allowing developers to control the layout and responsiveness of the table element.However, it is important to note that the <td> width attribute is not supported in HTML5. We have new ways now that favor the use of CSS for styling table elements, including specifying width.Note: The <td> width Attribute is not supported by HTML5.Syntax<td width="pixels | %">Attribute ValuesAttribute ValuesDescriptionspixelsIt sets the width of the table in terms of pixels.%It sets the width of the table in terms of percentage (%).Example 1: Using Pixels for <td> WidthIn the following example, we set the width of the first column in pixels. html <!DOCTYPE html> <html> <head> <title> HTML td width Attribute </title> </head> <body> <center> <h1 style="color: green;"> GeeksforGeeks </h1> <h3 style="color: crimson;"> HTML td width Attribute </h3> <table border="1" width="500"> <tr> <th>NAME</th> <th>AGE</th> <th>BRANCH</th> </tr> <tr> <td width="50%">BITTU</td> <td width="20%">22</td> <td width="30%">CSE</td> </tr> <tr> <td>RAKESH</td> <td>25</td> <td>EC</td> </tr> </table> </center> </body> </html> Output:Example 2: Using Percentage for <td> WidthIn this example, we set the width of the first column as a percentage of the total table width. HTML <!DOCTYPE html> <html> <head> <title> HTML td width Attribute </title> </head> <body> <center> <h1 style="color: green;"> GeeksforGeeks </h1> <h3 style="color: crimson;"> HTML td width Attribute </h3> <table border="1" width="80%"> <tr> <th>NAME</th> <th>AGE</th> <th>BRANCH</th> </tr> <tr> <td width="40%">BITTU</td> <td width="30%">22</td> <td width="30%">CSE</td> </tr> <tr> <td width="60%">RAKESH</td> <td width="20%">25</td> <td width="20%">EC</td> </tr> </table> </center> </body> </html> Output:Important Note on HTML5The <td> width attribute is deprecated in HTML5, meaning it is no longer supported in modern web development. Instead of using the width attribute in the <td> element, developers should now use CSS to control the width of table cells for better styling and responsiveness.Here’s an example of how to set the width of a table cell using CSS: HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Table Cell Width Using CSS</title> <style> td { width: 200px; /* Example of setting width in CSS */ } </style> </head> <body> <table border="1"> <tr> <td>Cell with width set using CSS</td> <td>Another cell</td> </tr> <tr> <td>Cell with width set using CSS</td> <td>Another cell</td> </tr> </table> </body> </html> Output: Supported BrowsersGoogle Chrome 1 and aboveMicrosoft Edge 12 and aboveFirefox 1 and aboveOpera 12.1 and aboveSafari 1 and aboveHTML is the foundation of webpages, is used for webpage development by structuring websites and web apps.You can learn HTML from the ground up by following this HTML Tutorial and HTML Examples. HTML <td> width Attribute Comment More infoAdvertise with us Next Article HTML width Attribute J jit_t Follow Improve Article Tags : Web Technologies HTML HTML-Attributes Similar Reads HTML <th> width Attribute The HTML <th> width Attribute is used to specify the width of a table header cell. If the width attribute is not set then it takes the default width according to the content. Syntax:<th width="pixels | %">Attribute Values:Attributes valuesDescriptionpixelsIt sets the width of the table h 2 min read HTML | <pre> width Attribute The HTML <pre> width Attribute is used to specify the maximum number of characters per line. Note: The width Attribute is not supported by HTML5 Syntax: <pre width="number"> Attribute Values: number: It is used to set the maximum number of characters. Example: html <!DOCTYPE html> 1 min read HTML <table> width Attribute The HTML <table> element's width attribute specifies the width of the table. It can accept values in pixels or percentages. However, in HTML5, it is recommended to control table width using CSS instead.Syntax<table width="pixels | %">Attribute Valuespixels: It sets the width of the table 2 min read HTML <object> width Attribute The HTML <object> width attribute is used to specify the horizontal dimension of the embedded object, defining the width of the displayed content within the webpage. Syntax: <object width="pixels">Attribute Values: pixels: It holds the width of the object in terms of pixels.The below exa 1 min read HTML | <input> width Attribute The HTML <input> width Attribute is used to specify the width of the <input> element. This Attribute is only used for input type="image". Syntax: <input width="pixels"> Attribute Values: It contains the value i.e pixels which specify the width of the input Element. Example: HTML 1 min read HTML | <col> width Attribute The HTML <col> width Attribute is used to specify the width of a column element. If width attribute is not set then it takes default width according to content. It is not supported by HTML 5. Syntax: <col width="pixels | % | relative_length"> Attribute Values: pixels: It sets the width o 1 min read Like We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy Got It ! Improvement Suggest changes Suggest Changes Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal. Create Improvement Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all. Suggest Changes min 4 words, max Words Limit:1000 Thank You! Your suggestions are valuable to us. What kind of Experience do you want to share? Interview Experiences Admission Experiences Career Journeys Work Experiences Campus Experiences Competitive Exam Experiences