html table mcq questions basic to advance
HTML tables are a very important topic in website development. Thatโs why we have brought HTML Table MCQ questions for you. By practicing these questions, you can improve your skills effectively.
Q1. Which tag is used first to create a table in HTML?
To create a table in HTML, the <table> tag is used first. It defines the beginning of the table structure.
Q2. Why is the <tr> tag used in an HTML table?
The <tr> tag is used to create a row in an HTML table. For every row in the table, a separate <tr> tag is used.
Q3. Which of the following tags is used to give a heading in a table?
The <th> tag is used to define a heading cell in an HTML table. The <td> tag is used for normal data cells, and <ht> is not a valid HTML tag.
Q4. Which of the following tags is NOT used to create a table?
The <ht> tag is not a valid HTML tag and is not used in creating a table.
Q5. Which attribute is used to merge two columns in an HTML table?
The colspan attribute is used to merge two or more columns in an HTML table. It combines multiple columns into a single column.
Q6. If we want to merge two rows in HTML, which is the correct code?
The rowspan attribute is used to merge two or more rows in an HTML table. Therefore, the correct code is <td rowspan='2'>Content</td>.
Q7. Which attribute is used to give a border around an HTML table?
The border attribute is used inside the <table> tag to add a border around the table.
Q8. What is the function of cellpadding in an HTML table?
The cellpadding attribute is used to create space between the cell content and the cell border in an HTML table.
Q9. Which of the following is the correct code to set a background color for a table row?
To set a background color for a table row, we use CSS with the style attribute, such as <tr style='background-color: yellow;'>. The bgcolor attribute is obsolete in HTML5.
Q10. Why is the <tfoot> tag used in an HTML table?
The <tfoot> tag is used to define the footer section of an HTML table, such as totals or summary information.