为什么重要
键盘用户和屏幕阅读器用户不想在每页按 Tab 过所有导航链接。跳过链接让他们绕过重复的导航,直接落在真正的内容上。
原理
- The link lives at the very top of
<body> - CSS 教程 hides it visually (
left: -9999px) except when focused - Its
href="#main"points to the<main>element - That
<main>hastabindex="-1"so it can receive programmatic focus
试试
先点击页面任意位置清掉已有焦点,然后反复按 Tab,看看焦点顺序。