How do we display the thickness of the border of an element in HTML?


Use the border attribute in HTML to display the thickness of the border.

Note − This attribute is not supported in HTML5.

Example

You can try to run the following code to learn how to implement border attribute in HTML −

<!DOCTYPE html>
<html>
   <body>
      <h2>Cricketers</h2>
      <table style="width:100%" border="1">
         <th>Name</th>
         <tr>
            <td>Sachin Tendulkar</td>
         </tr>
         <tr>
            <td>Virat Kohli</td>
         </tr>
      </table>
   </body>
</html>

Use CSS instead, since the border attribute deprecated in HTML5.

<!DOCTYPE html>
<html>
   <head>
      <style>
         table, th, td {
            border: 1px solid black;
         }
      </style>
   </head>
   <body>
      <h2>Cricketers</h2>
      <table style="width:100%">
         <caption>Indian Cricketers</caption>
         <th>Name</th>
         <tr>
            <td>Sachin Tendulkar</td>
         </tr>
         <tr>
            <td>Virat Kohli</td>
         </tr>
      </table>
   </body>
</html>

Updated on: 02-Mar-2020

110 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements