HTML <table> width Attribute

Last Updated : 22 May, 2026

The HTML <table> width attribute is used to specify the width of a table.

  • The width can be set in pixels or percentage.
  • It controls how wide the table appears on the webpage.
  • In modern HTML, CSS width property is preferred instead of the width attribute.

Syntax:

<table width="pixels | %">
  • pixels: It sets the width of the table in terms of pixels.
  • %: It sets the width of the table in terms of percentage (%).

Note: The <table> width Attribute is not supported by HTML 5.

Example: In this example we defines a table with a border and width of 250 pixels. It contains headings for "Name", "Age", and "Branch" with one row of data.

html
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>

<head>
    <title>
        HTML table width Attribute
    </title>
</head>

<body>
    <h1>GeeksforGeeks</h1>

    <h2>HTML table width Attribute</h2>

<!--Driver Code Ends-->

    <table border="1" width="250">
        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
        <tr>
            <td>Ben</td>
            <td>22</td>
            <td>CSE</td>
        </tr>
    </table>

<!--Driver Code Starts-->
</body>

</html>
<!--Driver Code Ends-->
Comment