A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/html/html-table-border-attribute/ below:

HTML table border Attribute - GeeksforGeeks

HTML table border Attribute

Last Updated : 11 Jul, 2025

The HTML <table> border Attribute is used to specify the border of a table. It sets the border around the table cells. This attribute defines the visual presentation of the table by setting the thickness of the borders. A higher value results in a thicker border. Alternatively, setting the border attribute to "0" removes the borders entirely.

Syntax:

<table border="value">

In this code:

The value represents the thickness of the border in pixels.

Now, let us understand with the help of the example:

HTML
<html>
<head>
    <style>
        body {
            text-align: center;
        }

        table {
            margin: 0 auto;
            height: 20vh;
            width: 40vh;
        }

        h1 {
            color: green;
        }
    </style>
</head>
<body>
    <h1>GeeksforGeeks</h1>
    <h2>HTML table border Attribute</h2>
    <table border="1">
        <caption>
            Author Details
        </caption>

        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
        <tr>
            <td>BITTU</td>
            <td>22</td>
            <td>CSE</td>
        </tr>
        <tr>
            <td>RAM</td>
            <td>21</td>
            <td>ECE</td>
        </tr>
    </table>
</body>
</html>

Output:

In this example:

Note: The border attribute is not supported by HTML5.

Collapsed Table Borders

To prevent the appearance of double borders in a table, you can use the CSS property 'border-collapse' and set it to "collapse." By doing so, the borders within the table will merge into a single border, providing a cleaner and more unified visual presentation.

Syntax:

table, th, td {
  border-collapse: collapse; 
}

Now, let us understand with the help of the example:

HTML
<html>
<head>
    <style>
        body {
            text-align: center;
        }
        table {
            margin: 0 auto;
            height: 20vh;
            width: 40vh;
        }
        table,
        th,
        td {
            border-collapse: collapse;
        }
        h1 {
            color: green;
        }
    </style>
</head>
<body>
    <h1>GeeksforGeeks</h1>
    <h2>HTML table border Attribute</h2>
    <table border="1">
        <caption>
            Author Details
        </caption>
        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
        <tr>
            <td>BITTU</td>
            <td>22</td>
            <td>CSE</td>
        </tr>
        <tr>
            <td>RAM</td>
            <td>21</td>
            <td>ECE</td>
        </tr>
    </table>
</body>

</html>

Output:

In this example:

Round Table Borders

For rounded table borders, apply the CSS 'border-radius' property to the table element with a specified radius value, creating a visually appealing circular border effect.

Syntax:

table, th, td {
  border-radius: 10px;
}

Now, let us understand with the help of the example:

HTML
<html>
<head>
    <title>
        HTML table border Attribute
    </title>
    <style>
        body {
            text-align: center;
        }
        table {
            margin: 0 auto;
            height: 20vh;
            width: 40vh;
        }
        table,
        th,
        td {
            border-radius: 15px;
        }
        h1 {
            color: green;
        }
    </style>
</head>
<body>
    <h1>GeeksforGeeks</h1>
    <h2>HTML table border Attribute</h2>
    <table border="1">
        <caption>
            Author Details
        </caption>

        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
        <tr>
            <td>BITTU</td>
            <td>22</td>
            <td>CSE</td>
        </tr>
        <tr>
            <td>RAM</td>
            <td>21</td>
            <td>ECE</td>
        </tr>
    </table>
</body>

</html>

Output:

In this example:

Dashed Table Borders

To use dashed table borders, use the CSS 'border-style' property and set it to "dashed" for the desired table cells. You can also use dotted , dashed , solid , double , groove , ridge , hidden , none etc.

Syntax:
table, th, td {   
      border-style: dashed; 
}

Now, let us understand with the help of the example:

HTML
<html>
<head>
    <title>
        HTML table border Attribute
    </title>
    <style>
        body {
            text-align: center;
        }

        table {
            margin: 0 auto;
            height: 20vh;
            width: 40vh;
        }

        table,
        th,
        td {
            border-style: dashed;
        }

        h1 {
            color: green;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>
    <h2>HTML table border Attribute</h2>
    <table border="1">
        <caption>
            Author Details
        </caption>
        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
        <tr>
            <td>BITTU</td>
            <td>22</td>
            <td>CSE</td>
        </tr>
        <tr>
            <td>RAM</td>
            <td>21</td>
            <td>ECE</td>
        </tr>
    </table>
</body>
</html>

Output:

In this example:

Limitations of the border Attribute

Although the border attribute is quick and easy to use, it has limitations:

Supported Browsers: Conclusion

The border attribute in HTML tables offers a simple and quick way to add borders, but it comes with limitations in terms of flexibility and customization. In modern web development, CSS should be used to style table borders because it provides much more control over appearance, such as adjusting border width, color, and style. Additionally, CSS is more versatile and future-proof for styling web pages.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4