시멘틱 HTML 우선 → 그래도 부족하면 ARIA. <div onClick> 은 한 번도 정답이 아니다. <button> 으로 시작하라. 그 다음 키보드 / 포커스 / 스크린리더 4가지 점검.
📖 핵심 개념
시멘틱: button / a / input / nav / main / section — 의미 가진 태그.
ARIA: 시멘틱이 부족할 때만. role / aria-label / aria-describedby 등.
키보드: Tab / Enter / Space / Esc / Arrow 동작.
포커스 trap: modal 안에 갇히도록.
announcement: live region 으로 동적 변화 알림.
💻 코드 패턴
Modal — focus trap + ESC + announcement
import{useEffect,useRef}from'react';importFocusTrapfrom'focus-trap-react';functionModal({open,onClose,title,children}){consttriggerRef=useRef<HTMLElement>();useEffect(()=>{if(open){triggerRef.current=document.activeElementasHTMLElement;constonKey=(e: KeyboardEvent)=>{if(e.key==='Escape')onClose();};document.addEventListener('keydown',onKey);return()=>{document.removeEventListener('keydown',onKey);triggerRef.current?.focus();// 닫힐 때 trigger 로 포커스 복귀
};}},[open,onClose]);if(!open)returnnull;return(<FocusTrap><divrole="dialog"aria-modal="true"aria-labelledby="dlg-title"><h2id="dlg-title">{title}</h2>{children}<buttononClick={onClose}aria-label="닫기">×</button></div></FocusTrap>);}