Tuesday, September 25, 2018

CSS Styling Tables

An HTML table is defined with the <table> tag.
Each table row is defined with the <tr> tag. A table header is defined with the <th> tag. By default, table headings are bold and centered. A table data/cell is defined with the <td> tag.
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
}
</style>
</head>
<body>

<h2>Add a border to a table:</h2>

<table>
  <tr>
    <th>Firstname</th>
    <th>Lastname</th>
  </tr>
  <tr>
    <td>James</td>
    <td>Bill</td>
  </tr>
  <tr>
    <td>Lois</td>
    <td>Peter</td>
  </tr>
</table>

</body>
</html>

No comments:

Post a Comment