Repeated menus can make keyboard users tab through the same links on every page. An HTML skip link gives them a shortcut straight to the main content.
A link to a fragment, such as #main-content, points to an element with that ID on the same page. Making the destination focusable lets the browser continue keyboard navigation from the main content.
A skip link can stay visible all the time. When the design hides it, the link needs to appear as soon as it receives keyboard focus.
Steps to add a skip link in HTML:
- Create skip-link.html in a new test folder using your text editor.
- Enter the starter markup for the garden page in skip-link.html.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Community garden</title> <style> body { margin: 4rem 2rem 2rem; font: 1.5rem/1.5 system-ui, sans-serif; } :focus-visible { outline: 3px solid #145da0; outline-offset: 4px; } </style> </head> <body> <header> <nav aria-label="Site"> <a href="#hours">Hours</a> ยท <a href="#location">Location</a> </nav> </header> <main> <h1>Community garden</h1> <p><a href="#location">Get directions</a></p> <h2 id="hours">Opening hours</h2> <p>Saturday and Sunday, 9 am to 4 pm.</p> <h2 id="location">Location</h2> <p>The entrance is beside the park gate.</p> </main> </body> </html>
- Add the destination ID and tabindex="-1" to the opening <main> tag.
<main id="main-content" tabindex="-1">The negative tab index lets the link move focus to <main> without making the region an extra Tab stop. An existing ID on <main> can serve as the destination. The skip link's fragment must match it.
- Add the skip-link CSS immediately before </style>.
.skip-link { position: absolute; top: 0.5rem; left: 2rem; padding: 0.25rem 0.5rem; background: white; clip-path: inset(50%); } .skip-link:focus { clip-path: none; }
The CSS clips the link while it is unfocused, leaving it in the tab order. The :focus rule reveals it above the navigation.
- Save skip-link.html.
- Open skip-link.html from its local file URL in desktop Chrome.
The file URL in the screenshot is file:///home/user/site/skip-link.html. Your folder path will differ.
- Press Tab from the top of the page to reveal Skip to main content.

- Press Enter on Skip to main content.
The blue focus outline moves to the main content and the address ends in #main-content.
- Press Tab again with the main content focused.

- Verify that Get directions inside the main content has the blue focus outline.
On your own page, the next Tab reaches the first tab stop inside <main>, if there is one. The browser skips disabled controls. If <main> has no tab stop, the focus move to <main> immediately after Enter confirms that the skip link works. W3C's skip-link technique describes this keyboard check.