HTML Interview10 Q&A

HTML Tables Interview

Interview questions on table structure, semantics, accessibility, and common pitfalls.

1Main tags in an HTML table?easy
Answer: table, tr, th, and td.
2Purpose of thead, tbody, tfoot?medium
Answer: They segment table sections for clarity, styling, and accessibility.
3When to use th vs td?easy
Answer: th is header cell, td is data cell.
4What is scope attribute in th?medium
Answer: It defines if header applies to row/column, helping screen readers map data correctly.
5Use of caption in tables?easy
Answer: Provides table title/description, improving context for users.
6rowspan and colspan meaning?medium
Answer: They merge cells across rows or columns.
7Should tables be used for page layout?easy
Answer: No. Use tables for tabular data only; use CSS layout for page structure.
8How to make wide tables mobile-friendly?medium
Answer: Wrap in responsive container with horizontal scrolling and clear headings.
9Accessibility tip for complex tables?medium
Answer: Use proper headers, scope, captions, and consistent cell associations.
10Interview best-practice summary?medium
Answer: Semantic sections + accessible headers + no layout misuse.
Tricky Q&A (10 Questions)
11tfoot can appear before tbody in HTML and:tricky
Answer: Correct answer: Still renders at table bottom. DOM order allows tfoot before tbody; displays at bottom.
12th scope='row' indicates:tricky
Answer: Correct answer: Row header cell. scope='row' labels that row.
13colgroup primarily styles:tricky
Answer: Correct answer: Entire columns. colgroup/col target columns collectively.
14Using tables for page layout is:tricky
Answer: Correct answer: Discouraged; use CSS layout. Tables are for tabular data, not page grids.
15caption element provides:tricky
Answer: Correct answer: Table title/description. caption names/describes the table.
16headers attribute on td links:tricky
Answer: Correct answer: Related th ids for complex tables. headers associates data cells with header ids.
17border attribute on table is:tricky
Answer: Correct answer: Obsolete; use CSS borders. Use CSS instead of legacy border attribute.
18empty cells should still:tricky
Answer: Correct answer: Include td/th for structure. Maintain grid structure with cells.
19thead typically contains:tricky
Answer: Correct answer: Header row cells. thead groups header rows.
20Responsive wide tables often:tricky
Answer: Correct answer: Use wrapper with overflow-x auto. Horizontal scroll wrappers preserve data tables on mobile.