Home  >  Article  >  Web Front-end  >  How can we display the border thickness of an element in HTML?

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

王林
王林forward
2023-09-07 21:33:07943browse

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

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

Note − HTML5 does not support this attribute.

Example

You can try running the following code to understand how to implement the 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>

Please use CSS as border is deprecated in HTML5 Attributes.

<!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>

The above is the detailed content of How can we display the border thickness of an element in HTML?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete