How does affordance guide choosing a native button over a styled div?

This tests if you see affordance as built-in behavior, not only looks. A strong answer picks the native button for free keyboard, focus, and reader support, noting a div needs tabindex, role, and keydown logic. A red flag is treating it as purely visual.
What's really being asked
The interviewer wants to know if you understand that affordance is not just how a component looks, but what it does for the user automatically. They are checking whether you can distinguish between visual mimicry and functional semantics, and whether you know the real maintenance cost of rebuilding native controls. This separates engineers who write markup from engineers who design robust interfaces.
The full answer
First, define affordance as the relationship between what an element looks like and what actions it supports. Second, state that a native button carries implicit contracts: it is focusable via keyboard, activatable with Enter or Space, announced correctly by screen readers, and included in form submission logic. Third, explain that a styled div is inert by default and must be augmented with tabindex to enter the tab order, role equals button to expose semantics, and JavaScript keydown handlers to respond to Enter and Space. Fourth, mention that native buttons also handle disabled states, focus rings, and mobile touch behavior without extra code. Fifth, note that while a div may be necessary for complex layouts, the default choice should be the semantic element.
The mistakes people make
Claiming that adding role equals button is enough, which ignores keyboard and focus requirements. Saying the choice is purely about CSS styling or design system consistency. Arguing that divs are lighter or faster without measuring real impact. Forgetting that form buttons have built-in submit behavior that divs cannot replicate. Ignoring the maintenance burden of polyfilling native behavior across browsers and assistive technologies.
What usually comes next
How would you handle a complex card component that needs to be clickable but contains other interactive elements? When is it acceptable to use a div with ARIA instead of a button? How do you prevent double submission or manage loading states differently between native and custom buttons? What happens to focus management when a custom button opens a modal?
A concrete example
Imagine a save action in a settings panel. Using a native button gives you keyboard activation, automatic focus on return from a dialog, and screen-reader announcement of the disabled state during submission. If you use a div, you must write keydown logic for Space and Enter, manage tabindex manually, and ensure aria-disabled is announced, all of which create regression risk when requirements change.
Interview question
Which factor does the concept of affordance prioritize when selecting a native button over a styled div?
- a.Reduced DOM weight and faster rendering performance
- b.Built-in keyboard support, focus handling, and screen reader semanticsCorrect
- c.Visual design consistency and CSS customization flexibility
- d.ARIA attributes alone as a substitute for native behavior
Why? this is the answer
Affordance centers on the built-in behavioral contracts of native elements, such as keyboard activation and screen reader announcements, rather than just appearance. Option D is tempting because developers often assume role='button' is sufficient, but that ignores the manual keyboard and focus management a div still requires.
Just read this? Test yourself on what you have been reading.
Read the original → developer.mozilla.org
- #accessibility
- #html
- #affordance
- #ui-design
- #aria
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on accessibility — each one lists the topics its interview covers.
See open roles