HTML Tables: 19 MCQs with answers

All 19 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 8 questions

Q1. Which HTML element is used to define a table row?

Beginner
A <table> B <th> C <td> D <tr>
Show answer & explanation

<tr>

The element defines a table row; defines a data cell, a header cell, and the table itself.

Q2. Which element is used to define a table header cell?

Beginner
A <td> B <caption> C <thead> D <th>
Show answer & explanation

<th>

defines a header cell, which is typically bold and centered by default.

Q3. What is the purpose of the <caption> element in a table?

Beginner
A To specify column width B To define a row of data C To group header content D To provide a title or description for the table
Show answer & explanation

To provide a title or description for the table

The element provides a title or description for the table, improving accessibility and context.

Q4. What is the default border value for an HTML table if no border attribute is specified?

Beginner
A 2 B 1 C 0 D No border is shown by default
Show answer & explanation

0

By default, tables have no border; you must add the border attribute or CSS to show borders.

Q5. Which attribute is used to define the number of columns a table should have?

Beginner
A width B None; columns are defined by cells in rows C colspan D cols
Show answer & explanation

None; columns are defined by cells in rows

HTML tables do not have a 'cols' attribute; columns are implicitly defined by the number of cells in each row.

Q6. What is the correct HTML for adding a caption to a table?

Beginner
A <header>Monthly Sales</header> B <table-caption>Monthly Sales</table-caption> C <caption>Monthly Sales</caption> D <title>Monthly Sales</title>
Show answer & explanation

<caption>Monthly Sales</caption>

The element is placed directly inside the element to provide a title.

Q7. Which element is used to define a data cell in a table?

Beginner
A <tr> B <data> C <th> D <td>
Show answer & explanation

<td>

stands for table data and is used for standard cells containing data.

Q8. What is the default alignment of text in a <th> element?

Beginner
A Center B Left C Justified D Right
Show answer & explanation

Center

By default, text is centered and bold, unlike which is left-aligned by default.

Building up · 9 questions

Q9. Which attribute is used to merge two or more columns in a table cell?

Intermediate
A merge B rowspan C span D colspan
Show answer & explanation

colspan

The colspan attribute specifies how many columns a cell should span horizontally.

Q10. Which attribute is used to merge two or more rows in a table cell?

Intermediate
A span B colspan C rowmerge D rowspan
Show answer & explanation

rowspan

The rowspan attribute specifies how many rows a cell should span vertically.

Q11. Which element is used to group the body content of a table?

Intermediate
A <table-body> B <tbody> C <thead> D <tfoot>
Show answer & explanation

<tbody>

groups the main data rows of a table, helping with structure and styling.

Q12. Which element is used to group the header content of a table?

Intermediate
A <header> B <thead> C <th> D <caption>
Show answer & explanation

<thead>

is used to group the header rows of a table, typically containing elements.

Q13. Which element is used to group the footer content of a table?

Intermediate
A <footer> B <tfoot> C <tf> D <table-footer>
Show answer & explanation

<tfoot>

groups the footer rows of a table, often used for summaries or totals.

Q14. What is the purpose of the scope attribute on a <th> element?

Intermediate
A To associate a header cell with a row or column B To define the alignment of the header text C To merge header cells D To specify the width of the header cell
Show answer & explanation

To associate a header cell with a row or column

The scope attribute indicates whether a header cell applies to a row (scope="row") or column (scope="col"), improving accessibility.

Q15. Which of the following is a best practice for creating accessible tables?

Intermediate
A Using inline styles for borders B Using <th> with scope attributes for header cells C Using <td> for all cells including headers D Omitting the <caption> element
Show answer & explanation

Using <th> with scope attributes for header cells

Using with scope attributes helps screen readers understand the table structure, making it accessible.

Q16. The <tfoot> element must appear after all <tr> elements in the table.

Intermediate
A True B False
Show answer & explanation

False

In HTML5, can appear before or after , but it must be after and can be before or after ; it is not required to be at the end.

Q17. The border attribute is deprecated in HTML5 for tables.

Intermediate
A True B False
Show answer & explanation

True

The border attribute is deprecated in HTML5; CSS is recommended for styling borders.

Topper level · 2 questions

Q18. Which attribute was used in older HTML to specify the space between cell borders?

Advanced
A cellspacing B border-spacing C margin D cellpadding
Show answer & explanation

cellspacing

The cellspacing attribute (deprecated in HTML5) controlled the space between cells; CSS border-spacing is now preferred.

Q19. Which attribute was used in older HTML to specify the space inside a cell between the content and the cell border?

Advanced
A padding B cellpadding C inner-margin D cellspacing
Show answer & explanation

cellpadding

The cellpadding attribute (deprecated in HTML5) controlled the space inside cells; CSS padding is now preferred.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages