Halloween Sale 15% off Ends in See the plans
HTML

"Skip to Content" Link

Adds a hidden "Skip to content" link that appears when keyboard users press Tab, letting them jump past the header and menu, for themes that lack one.

Don’t have WPIDE yet? Install it on your site

Code

<a class="wpide-skip-link" href="#main">Skip to content</a>
<style>
.wpide-skip-link{position:absolute;left:-9999px;top:0;z-index:100001;padding:10px 16px;background:#1e1e1e;color:#fff;text-decoration:none;}
.wpide-skip-link:focus{left:10px;top:10px;}
</style>
<script>
(function () {
    var link = document.querySelector('.wpide-skip-link');
    var target = document.querySelector('#main, main, .site-main, #content');
    if (!link || !target) { return; }
    if (!target.id) { target.id = 'wpide-main'; }
    if (!target.hasAttribute('tabindex')) { target.setAttribute('tabindex', '-1'); }
    link.setAttribute('href', '#' + target.id);
})();
</script>

Notes

The link targets #main, main or .site-main, whichever exists first. Your theme must call wp_body_open.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.