Question:

Write the HTML code to create a table with 2 rows and 2 columns and a border of 2. The first row should be the table header containing Roll No and Name, and the second row should contain the values 1 and Rahul respectively.

Show Hint

Start with the table tag and its border attribute, then use th cells for the first row and td cells for the second.
Updated On: Nov 3, 2026
Show Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

Step 1: Recall the table tags:
<table> starts the table. <tr> makes one row. <th> makes a header cell, and <td> makes an ordinary data cell. The border attribute of <table> sets the thickness of the table lines.

Step 2: Plan the structure:
We need 2 rows and 2 columns. So there are two <tr> tags and two cells inside each. Row 1 is the header, so its cells use <th> with Roll No and Name. Row 2 holds data, so its cells use <td> with 1 and Rahul.

Step 3: Write the code:
<table border="2">
  <tr>
    <th>Roll No</th>
    <th>Name</th>
  </tr>
  <tr>
    <td>1</td>
    <td>Rahul</td>
  </tr>
</table>


Step 4: Check the result:
The table has 2 rows and 2 columns. The border value is 2. The first row shows bold, centred headings Roll No and Name, and the second row shows 1 and Rahul.

Final Answer:
The table is built with the table tag and border 2, one row of th cells and one row of td cells. \[ \boxed{\text{table border 2 with a th row (Roll No, Name) and a td row (1, Rahul)}} \]
Was this answer helpful?
0
0

Top CBSE X Questions

View More Questions