Image modals present media in focus view. Styling should prioritize clarity, escape affordance, and background separation.
Modal styling goals
- Backdrop contrast that keeps image focus.
- Clear close affordance and keyboard focus visibility.
- Responsive sizing so media fits viewport safely.
A11y warning
Modal overlays require focus management and escape handling in behavior layer; CSS alone is not enough.
Important interview questions and answers
- Q: Why is modal accessibility mostly not a CSS problem?
A: Focus trapping, aria roles, and escape key handling are behavioral requirements. - Q: What CSS issue breaks modal usability most?
A: Missing viewport-fit constraints causing clipped content on small screens. - Q: Why include backdrop blur/shade?
A: It isolates task focus and improves visual hierarchy.
Practice: Change one property in the playground and observe cascade + layout in DevTools.