Components

Skip link

Use the skip link component to help keyboard-only users skip to the main content on a page.

<p class="govuk-body">To view the skip link component tab to this example, or click inside this example and press tab.</p>

<a href="#content" class="govuk-skip-link">Skip to main content</a>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

Primary options
Name Type Description
text string Required. If html is set, this is not required. Text to use within the skip link component. If html is provided, the text argument will be ignored.
html string Required. If text is set, this is not required. HTML to use within the skip link component. If html is provided, the text argument will be ignored.
href string Required. The value of the skip link href attribute. Defaults to
classes string Classes to add to the skip link.
attributes object HTML attributes (for example data attributes) to add to the skip link.
<p class="govuk-body">To view the skip link component tab to this example, or click inside this example and press tab.</p>

{% from "skip-link/macro.njk" import govukSkipLink %}

{{ govukSkipLink({
  text: "Skip to main content",
  href: "#content"
}) }}

When to use this component

All GOV.UK pages must include a skip link in the header.

How it works

Some people use the tab key on their keyboard to navigate through the links and form elements on a web page.

Including the skip link component gives users the option to bypass the top-level navigation links and jump to the main content on a page.

The skip link component is visually hidden until a keyboard press activates it.

There are 2 ways to use the skip link component. You can use HTML or, if you are using Nunjucks or the GOV.UK Prototype Kit, you can use the Nunjucks macro.

<p class="govuk-body">To view the skip link component tab to this example, or click inside this example and press tab.</p>

<a href="#content" class="govuk-skip-link">Skip to main content</a>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as "Required" in the option description.

If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.

Primary options
Name Type Description
text string Required. If html is set, this is not required. Text to use within the skip link component. If html is provided, the text argument will be ignored.
html string Required. If text is set, this is not required. HTML to use within the skip link component. If html is provided, the text argument will be ignored.
href string Required. The value of the skip link href attribute. Defaults to
classes string Classes to add to the skip link.
attributes object HTML attributes (for example data attributes) to add to the skip link.
<p class="govuk-body">To view the skip link component tab to this example, or click inside this example and press tab.</p>

{% from "skip-link/macro.njk" import govukSkipLink %}

{{ govukSkipLink({
  text: "Skip to main content",
  href: "#content"
}) }}

Research on this component

If you’ve used this component, get in touch to share your user research findings.

Get in touch

If you’ve got a question, idea or suggestion share it in #govuk-design-system on cross-government Slack (open in app) or email the Design System team on govuk-design-system-support@digital.cabinet-office.gov.uk

Discuss ‘Skip link’ on GitHub