Question:

Create an HTML Table showing "Subject" and "Marks" with a border of 2 pixels.

Updated On: Feb 27, 2026
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

Concept: Creating a Table in HTML

  • <table> defines the table.
  • border attribute sets the border thickness.
  • <tr> defines rows.
  • <th> defines table headings.
  • <td> defines table data cells.


 

Step 1: Create the Table Structure

Use the <table> tag with border="2".


 

Step 2: Add Table Headings

Use <th> for column titles: Subject and Marks.


 

Step 3: Add Data Rows

Insert rows using <tr> and data using <td>.


 

Step 4: Complete HTML Code

<!DOCTYPE html> <html> <head>    <title>Subject Marks Table</title> </head> <body> <table border="2">    <tr>        <th>Subject</th>        <th>Marks</th>    </tr>    <tr>        <td>Maths</td>        <td>90</td>    </tr>    <tr>        <td>Science</td>        <td>85</td>    </tr> </table> </body> </html>
 

Conclusion

The table displays Subject and Marks with a 2-pixel border using the border="2" attribute.

Was this answer helpful?
0
0