Zed-King Institute

    Simple HTML Table with Header Row and Border

    easyTablesHTML

    Tables arrange data in rows and columns and appear in almost every M2 practical paper.

    The question

    Make a table with border="1". The first row must be a header row (<th>) with Name and City. Then add 4 rows for: Neha, Pooja, Sunil, Kiran (any city).

    The code

    index.html

    <table border="1">
      <tr><th>Name</th><th>City</th></tr>
      <tr><td>Neha</td><td>Kaithal</td></tr>
      <tr><td>Pooja</td><td>Kaithal</td></tr>
      <tr><td>Sunil</td><td>Kaithal</td></tr>
      <tr><td>Kiran</td><td>Kaithal</td></tr>
    </table>

    Result

    How it works

    1. 1<table border="1"> starts the table with visible borders.
    2. 2Each row is a <tr>.
    3. 3Header cells use <th> (bold and centred by default); normal cells use <td>.

    Common mistakes

    • Putting <td> directly in <table> without a <tr>.
    • Different numbers of cells in different rows, which breaks the columns.

    Now solve a similar question yourself

    A new HTML / CSS / JS question every time, checked instantly.

    Practice questions

    More in Tables