Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Accessibility Skip links


Why

People using keyboard, screen readers, switch controls and other assistive technologies use skip links to reach main content or other important sections easier and faster.


What

The most common skip link is the first interactive element on a page. It takes the user to the main content, past the global elements like the logo, search and navigation. It is almost always hidden until it receives focus.

Screenshot from WebAIM, showing the link skip to main content in the upper left corner.

How

Try it yourself

  1. Open the website WebAIM on your desktop or laptop.
  2. Press the tab key
  3. Press enter to follow the link.


HTML

The HTML of a skip link is the easy part.

Let's assume that you have used a <header> and a <main> in your site, as you learned in Landmarks. The skip link is a global element, so you should include it in the <header>. You also need to have an ID on the <main>, so that you are able to link to it with an anchor.

<header>
<a href="#main" class="skip">Skip to main content</a>

</header>

<main id="main">

That's it. No JavaScript. A link and an ID.


CSS

As you might noticed in the HTML, the link had the class skip, so that we are able to hide it. 

.skip {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

This code moves the link way outside of the browser. If you are not familiar with absolute positioning, read about the CSS position property. The 1px size and the overflow: hidden; are for special cases where user has deactivated absolute positioning.

When the link is focused, it has to be visible. This is also done with CSS:

.skip:focus {
  position: static;
  width: auto;
  height: auto;
}

This method is very helpful and important for users that rely on keyboard and similar input. If you have a complex site, you might want to add more skip links, not only to the main content. We will cover that later.



×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.