DEV Community

Cover image for HTML Tables
VECTOR3Studio
VECTOR3Studio

Posted on

HTML Tables

HTML tables allow web developers to arrange data into rows and columns.

The <table> tag defines an HTML table.

Each table row is defined with a <tr> tag. Each table header is defined with a <th> tag. Each table data/cell is defined with a <td> tag.

By default, the text in <th> elements are bold and centered.

By default, the text in <td> elements are regular and left-aligned.

This is example of Basic table.

<table style="width:100%">
  <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Megan</td>
    <td>Smith</td>
    <td>50</td>
  </tr>
  <tr>
    <td>Michael</td>
    <td>Jackson</td>
    <td>94</td>
  </tr>
</table>
Enter fullscreen mode Exit fullscreen mode

BONUS: How to make border.

table, th, td {
  border: 1px solid black;
}
Enter fullscreen mode Exit fullscreen mode

Thanks for reading :)

Top comments (0)