Web Technologies - Old Questions

5.  How can you draw a table in HTML? Discuss with suitable example.

5 marks | Asked in 2071-II

Tables are defined with the <table> tag. A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the <td> tag). The letters td stands for "table data," which is the content of a data cell. A data cell can contain text, images, lists, paragraphs, forms, horizontal rules, tables, etc. Headings in a table are defined with <th> tag.

Table tags:

Table tags attributes:

E.g.

<!DOCTYPE html>

<html>

<head>

<title>Table</title>

</head>

<body>

<h1>The table element</h1>

<table border="1">

  <tr>

    <th>Month</th>

    <th>Savings</th>

  </tr>

  <tr>

    <td>January</td>

    <td>$100</td>

  </tr>

  <tr>

    <td>February</td>

    <td>$80</td>

  </tr>

</table>

</body>

</html>