HTML Interview Questions: Semantics and Accessibility
Thirty questions on the topic that appears in almost every front end interview now, and where vague answers are most obvious.
- SQL Interview
-
HTML Interview
- HTML Interview Questions: Fundamentals
- HTML Interview Questions: Forms, Tables and Media
- HTML Interview Questions: Semantics and Accessibility
- HTML Interview Questions: SEO, Performance and Tooling
- Scenario Based Interview Questions
- Rapid Fire and Fresher Round Questions
- Live Coding and Project Explanation Rounds
Why this comes up so often
Accessibility has moved from a specialist concern to a baseline expectation, and it is legally required for a growing number of organisations. It is now a standard interview topic even for junior roles.
It is also a topic where vague answers stand out badly. Accessibility is important is not an answer. A div with a click handler is not focusable, so a keyboard user cannot reach it at all is.
Questions only.
Semantic HTML
- What is semantic HTML and why does it matter? Give four concrete benefits.
- Two pages look identical, one built from divs and one from semantic elements. What can the second do that the first cannot?
- Does a class name such as
class="navigation"convey anything to a browser? Explain. - Name the sectioning elements HTML5 introduced and what each is for.
- How do you decide between
article,sectionandaside? - How many
mainelements may a page have, and what may it not be nested inside? - When is a
headerelement a banner landmark and when is it not? - What is the difference between
sectionanddiv? - Is it wrong to use
div? When is it the correct choice? - What does the
timeelement give you that plain text does not? - What is
detailsandsummaryfor, and what does it replace? - Why does markup order matter more than visual order?
Accessibility fundamentals
- What does web accessibility mean, and who benefits?
- What are the four WCAG principles? Which conformance level is the practical target?
- Name the most common accessibility failures found on real sites.
- What is an accessible name, and where does a browser look for one?
- What is the difference between
aria-labelandaria-labelledby? When would you use each? - What is
aria-describedbyfor, and how does it differ from a label? - What is the first rule of ARIA?
- Does
role="button"on adivmake it a button? Explain fully. - Name three ARIA attributes you have actually used and what each did.
- Why is incorrect ARIA worse than no ARIA?
Keyboard and focus
- Which elements are focusable by default?
- What are the three values of
tabindexand when is each appropriate? - Why should you never use a positive
tabindex? - Why is removing the focus outline a problem, and what is the correct approach?
- What is a skip link and why does its target need
tabindex="-1"? - Name four ways to hide an element and say which leave it focusable.
- What is a focus trap? When is one correct and when is it a bug?
- How would you manage focus after a route change in a single page application?
Practical questions
- How would you test a page for accessibility? What do automated tools miss?
- Walk me through making an icon only button accessible.
- A designer gives you light grey text on white. What do you do?
- How would you build a modal dialog? What does the native element give you for free?
- How do you convey an error state without relying on colour?
What a strong answer looks like
These questions are asked to find out whether you have done the work, not whether you have read about it. Three things distinguish a strong answer:
- A specific failure mode. The reader tabs into something invisible beats it is not accessible.
- Something you built. I found this when I tested a filter I had written - the hidden items were still in the tab order.
- A named tool or technique. I check the computed name in the accessibility pane.
If you have never used a screen reader, spend thirty minutes with one before an interview. Being able to say when I tested this with a screen reader and describe what you heard is worth more than any amount of theory.
Practice
- Answer all thirty five out loud, giving a concrete example for each.
- Spend thirty minutes navigating a real site with a screen reader and write down three things that surprised you.
- Take a page you built and find three accessibility problems in it. Those become your interview examples.
- Explain the first rule of ARIA to someone who does not write code.