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?mediumAnswer: They segment table sections for clarity, styling, and accessibility.
3When to use
th vs td?easyAnswer:
th is header cell, td is data cell.4What is
scope attribute in th?mediumAnswer: It defines if header applies to row/column, helping screen readers map data correctly.
5Use of
caption in tables?easyAnswer: Provides table title/description, improving context for users.
6
rowspan and colspan meaning?mediumAnswer: 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.