Set the number of columns to span in HTML

HTMLWeb DevelopmentFront End Technology

Use the span attribute to set the number of columns to span in HTML. You can try to run the following code to implement span attribute −

Example

<!DOCTYPE html>
<html>
   <head>
      <style>
         table, th, td {
            border: 1px solid black;
         }
      </style>
   </head>
   <body>
      <table>
         <colgroup>
            <col span = "1" style = "background-color:grey">
         </colgroup>
         <tr>
            <th>S.NO</th>
            <th>Name</th>
         </tr>
         <tr>
            <td>1</td>
            <td>Amit</td>
         </tr>
      </table>
   </body>
</html>
raja
Updated on 03-Mar-2020 11:15:49

Advertisements