How to create table rows & columns in HTML?

HTMLWeb DevelopmentFront End Technology

To create table rows and columns in HTML, use the <table> tag. A table consist of rows and columns, which can be set using one or more <tr>, <th>, and <td> elements. A table row is defined by the <tr> tag. For table rows and columns, <tr> tag and <td> tag is used respectively. The <td> tag

Just keep in mind, a lot of table attributes such as align, bgcolor, border, cellpadding, cellspacing aren’t supported by HTML5. Do not use them. Use the style attribute to add CSS properties for adding a border to the table. We’re also using the <style> tag to style the table borders.

Example

You can try to run the following code to create table rows and columns in HTML.

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         table, th, td {
            border: 1px solid black;
         }
      </style>
   </head>

   <body>
      <h2>Understanding Tables</h2>
      <table>
         <tr>
            <th>Header: This is row1 column1</th>
            <th>Header: This is row1 column2</th>
         </tr>
         <tr>
            <td>This is row2 column1</td>
            <td>This is row2 column2</td>
         </tr>
      </table>
   </body>
</html>
raja
Published on 01-Feb-2018 11:20:59
Advertisements