HTML <th> width Attribute Last Updated : 16 Sep, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 header cell in terms of pixels.%It sets the width of the table header cell in terms of percentage (%).Example: In this example the <th> width attribute in this HTML example specifies the width of each table header cell in percentages. It adjusts the columns' widths to 50%, 20%, and 30% of the table's width. HTML <!DOCTYPE html> <html> <head> <title> HTML th width Attribute </title> </head> <body> <h1>GeeksforGeeks</h1> <h2>HTML th width Attribute</h2> <table border="1" width="500"> <tr> <th width="50%">NAME</th> <th width="20%">AGE</th> <th width="30%">BRANCH</th> </tr> <tr> <td>BITTU</td> <td>22</td> <td>CSE</td> </tr> <tr> <td>RAKESH</td> <td>25</td> <td>EC</td> </tr> </table> </body> </html> Output:Example: In this example we use the <th> width attribute to set specific widths for table headers: 100 pixels for "Header 1" and 200 pixels for "Header 2," with "Header 3" taking the remaining space. HTML <!DOCTYPE html> <html> <head> <title>Table with th Width Attribute</title> <style> body { display: flex; justify-content: center; align-items: center; flex-direction: column; } </style> </head> <body> <h1 style="color: green;">GeeksforGeeks</h1> <table border="1"> <tr> <th width="100">Header 1</th> <th width="200">Header 2</th> <th>Header 3</th> </tr> <tr> <td>Data 1</td> <td>Data 2</td> <td>Data 3</td> </tr> </table> </body> </html> Output:Output 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 <td> width Attribute 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 3 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