
The Border Table HTML attribute is used to apply a border in a table. We can use this attribute to apply borders around our table cells. The border table attribute in HTML highlights the border by setting the thickness where a value “0” removes the border while a higher value results in a thick border line around the table.
Any number other than “0” will result in a thick visible border line around the table. Let us know how to apply and use the border table html attribute.
You can use different variants of the border table HTML check below.
However, when we increase the border attribute value to “4” then the border thickness will significantly increase. You can easily notice it around the table.
Let’s check for an abruptly larger value of the border i,e. 80 attributes are given below.
The border has covered the entire blank area. Well, you can check on yourself how that changes around for any random values.
Also, check What are the font families in HTML?
Check an example of the code implementation of the border table html attribute below.
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" href="style.css" /> <title>Browser</title> </head> <body> <table border="2"> <caption> Student Details </caption> <tr> <th>NAME</th> <th>AGE</th> <th>BRANCH</th> <th>Roll No</th> </tr> <tr> <td>Aman</td> <td>22</td> <td>CSE</td> <td>123</td> </tr> <tr> <td>Harsh</td> <td>21</td> <td>ECE</td> <td>456</td> </tr> <tr> <td>Ankit</td> <td>23</td> <td>CSE</td> <td>345</td> </tr> <tr> <td>Aditya</td> <td>22</td> <td>MECH</td> <td>123</td> </tr> <tr> <td>Ashutosh</td> <td>21</td> <td>CIVIL</td> <td>123</td> </tr> </table> <script src="script.js"></script> </body> </html> |
| <table border="2"> //First we keep it to “2” <table border="2"> // Now, we changed the value of the attribute to “4” <table border="80”> We tried “80” too. |
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" href="style.css" /> <title>Browser</title> </head> <body> <table border="0"> <caption> Student Details </caption> <tr> <th>NAME</th> <th>AGE</th> <th>BRANCH</th> <th>Roll No</th> </tr> <tr> <td>Aman</td> <td>22</td> <td>CSE</td> <td>123</td> </tr> <tr> <td>Harsh</td> <td>21</td> <td>ECE</td> <td>456</td> </tr> <tr> <td>Ankit</td> <td>23</td> <td>CSE</td> <td>345</td> </tr> <tr> <td>Aditya</td> <td>22</td> <td>MECH</td> <td>123</td> </tr> <tr> <td>Ashutosh</td> <td>21</td> <td>CIVIL</td> <td>123</td> </tr> </table> <script src="script.js"></script> </body> </html> |
| Attribute Value | Description |
| Any number other than zero | Sets the border around the table based on the value given border thickness changes |
| 0 (Zero) | It removes the border around the table cells |
| table, th, td { border-collapse: collapse; } |
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" href="style.css" /> <title>Browser</title> <style> table, th, td { border-collapse: collapse; } </style> </head> <body> <table border="2"> <caption> Student Details </caption> <tr> <th>NAME</th> <th>AGE</th> <th>BRANCH</th> <th>Roll No</th> </tr> <tr> <td>Aman</td> <td>22</td> <td>CSE</td> <td>123</td> </tr> <tr> <td>Harsh</td> <td>21</td> <td>ECE</td> <td>456</td> </tr> <tr> <td>Ankit</td> <td>23</td> <td>CSE</td> <td>345</td> </tr> <tr> <td>Aditya</td> <td>22</td> <td>MECH</td> <td>123</td> </tr> <tr> <td>Ashutosh</td> <td>21</td> <td>CIVIL</td> <td>123</td> </tr> </table> <script src="script.js"></script> </body> </html> |
| table, th, td { border-radius: 5px; } |
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" href="style.css" /> <title>Browser</title> <style> table, th, td { border-radius: 5px; } </style> </head> <body> <table border="2"> <caption> Student Details </caption> <tr> <th>NAME</th> <th>AGE</th> <th>BRANCH</th> <th>Roll No</th> </tr> <tr> <td>Aman</td> <td>22</td> <td>CSE</td> <td>123</td> </tr> <tr> <td>Harsh</td> <td>21</td> <td>ECE</td> <td>456</td> </tr> <tr> <td>Ankit</td> <td>23</td> <td>CSE</td> <td>345</td> </tr> <tr> <td>Aditya</td> <td>22</td> <td>MECH</td> <td>123</td> </tr> <tr> <td>Ashutosh</td> <td>21</td> <td>CIVIL</td> <td>123</td> </tr> </table> <script src="script.js"></script> </body> </html> |
| table, th, td { border-style: dashed; } |
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" href="style.css" /> <title>Browser</title> <style> table, th, td { border-style: dashed; } </style> </head> <body> <table border="2"> <caption> Student Details </caption> <tr> <th>NAME</th> <th>AGE</th> <th>BRANCH</th> <th>Roll No</th> </tr> <tr> <td>Aman</td> <td>22</td> <td>CSE</td> <td>123</td> </tr> <tr> <td>Harsh</td> <td>21</td> <td>ECE</td> <td>456</td> </tr> <tr> <td>Ankit</td> <td>23</td> <td>CSE</td> <td>345</td> </tr> <tr> <td>Aditya</td> <td>22</td> <td>MECH</td> <td>123</td> </tr> <tr> <td>Ashutosh</td> <td>21</td> <td>CIVIL</td> <td>123</td> </tr> </table> <script src="script.js"></script> </body> </html> |