Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Set Fixed Width for Table Cells</title> <style> table { width: 300px; } th, td { width: 50%; } table.fixed { table-layout: fixed; } table, th, td{ border: 1px solid black; } </style> </head> <body> <table> <caption>Example 1. Auto</caption> <tr> <th>Name</th> <th>Email</th> </tr> <tr> <td>John Carter</td> <td>johncarter@example.com</td> </tr> </table> <br> <table class="fixed"> <caption>Example 2. Fixed</caption> <tr> <th>Name</th> <th>Email</th> </tr> <tr> <td>Peter Parker</td> <td>peterparker@example.com</td> </tr> </table> <p><strong>Note:</strong> As you can see the width of table cell does not change to accommodate the content in fixed table-layout.</p> </body> </html>