Skip link
Use the skip link component to help keyboard-only users skip to the main content on a page.
<div class="app-example app-example--tabs">
<div class="app-example__toolbar">
<a href="/components/skip-link/default/index.html" class="app-example__new-window" target="_blank">
Open this
<span class="govuk-visually-hidden">skip link</span>
example in a new tab
</a>
</div>
<iframe title="Skip link example" data-module="app-example-frame" class="app-example__frame app-example__frame--resizable" src="/components/skip-link/default/index.html" frameBorder="0" loading="lazy"></iframe>
</div>
<span id="options-skip-link-example"></span>
<ul class="app-tabs" role="tablist">
<li class="app-tabs__item js-tabs__item" role="presentation"><a href="#skip-link-example-html" role="tab" aria-controls="skip-link-example-html" data-track="tab-html">HTML</a></li>
<li class="app-tabs__item js-tabs__item" role="presentation"><a href="#skip-link-example-nunjucks" role="tab" aria-controls="skip-link-example-nunjucks" data-track="tab-nunjucks">Nunjucks</a></li>
</ul>
<div class="app-tabs__heading js-tabs__heading"><a href="#skip-link-example-html" aria-controls="skip-link-example-html" data-track="tab-html">HTML</a></div>
<div class="app-tabs__container js-tabs__container" id="skip-link-example-html" role="tabpanel">
<div class="app-example__code">
<pre data-module="app-copy" tabindex="0"><code class="hljs html"><span class="hljs-tag"><<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"govuk-body"</span>></span>To view the skip link component tab to this example, or click inside this example and press tab.<span class="hljs-tag"></<span class="hljs-name">p</span>></span>
<a href="#content" class="govuk-skip-link" data-module="govuk-skip-link">Skip to main content</a>
<div class="app-tabs__heading js-tabs__heading"><a class="app-tabs__heading-link" href="#skip-link-example-nunjucks" aria-controls="skip-link-example-nunjucks" data-track="tab-nunjucks">Nunjucks</a></div>
<div class="app-tabs__container js-tabs__container" id="skip-link-example-nunjucks" role="tabpanel">
<details class="govuk-details app-options" data-module="govuk-details" id="options-skip-link-example-details">
<p>
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
</p>
<p>
Some options are required for the macro to work; these are marked as "Required" in the option description.
</p>
<p>
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against <a href="https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting">cross-site scripting exploits</a>.
</p>
<table class="govuk-table app-options__table" id="options-skip-link-example--primary">
<caption class="govuk-table__caption govuk-heading-m govuk-visually-hidden">Primary options</caption>
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th class="govuk-table__header app-options__limit-table-cell" scope="col">Name</th>
<th class="govuk-table__header app-options__limit-table-cell" scope="col">Type</th>
<th class="govuk-table__header" scope="col">Description</th>
</tr>
</thead>
<tbody class="govuk-table__body">
<tr class="govuk-table__row">
<th class="govuk-table__header" scope="row">text</th>
<td class="govuk-table__cell ">string</td>
<td class="govuk-table__cell ">
<strong>Required.</strong>
If <code>html</code> is set, this is not required. Text to use within the skip link component. If <code>html</code> is provided, the <code>text</code> option will be ignored.
</td>
</tr>
<tr class="govuk-table__row">
<th class="govuk-table__header" scope="row">html</th>
<td class="govuk-table__cell ">string</td>
<td class="govuk-table__cell ">
<strong>Required.</strong>
If <code>text</code> is set, this is not required. HTML to use within the skip link component. If <code>html</code> is provided, the <code>text</code> option will be ignored.
</td>
</tr>
<tr class="govuk-table__row">
<th class="govuk-table__header" scope="row">href</th>
<td class="govuk-table__cell ">string</td>
<td class="govuk-table__cell ">
The value of the skip link’s <code>href</code> attribute. Defaults to <code>#content</code> if you do not provide a value.
</td>
</tr>
<tr class="govuk-table__row">
<th class="govuk-table__header" scope="row">classes</th>
<td class="govuk-table__cell ">string</td>
<td class="govuk-table__cell ">
Classes to add to the skip link.
</td>
</tr>
<tr class="govuk-table__row">
<th class="govuk-table__header" scope="row">attributes</th>
<td class="govuk-table__cell ">object</td>
<td class="govuk-table__cell ">
HTML attributes (for example data attributes) to add to the skip link.
</td>
</tr>
</tbody>
</table>
<div class="app-example__code">
<pre data-module="app-copy" tabindex="0"><code class="hljs js"><p <span class="hljs-keyword">class</span>=<span class="hljs-string">"govuk-body"</span>><span class="hljs-title class_">To</span> view the skip link component tab to <span class="hljs-variable language_">this</span> example, or click inside <span class="hljs-variable language_">this</span> example and press tab.</p>
{% from "govuk/components/skip-link/macro.njk" import govukSkipLink %} {{ govukSkipLink({ text: "Skip to main content", href: "#content" }) }}