Components

Back link

Use the back link component to help users go back to the previous page in a multi-page transaction.

<a href="#" class="govuk-back-link">Back</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 back 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 back link component. If html is provided, the text argument will be ignored.
href string Required. The value of the link href attribute.
classes string Classes to add to the anchor tag.
attributes object HTML attributes (for example data attributes) to add to the anchor tag.
{% from "back-link/macro.njk" import govukBackLink %}

{{ govukBackLink({
  text: "Back",
  href: "#"
}) }}

When to use this component

Always include the back link component on GOV.UK question pages.

You can include a back link on other pages within a multi-page transaction, if it makes sense to do so.

When not to use this component

Never use the back link component together with breadcrumbs. If necessary, you should do research with your users to learn which they find more helpful in your service.

How it works

Back links must always go at the top of a page.

Make sure the link takes users to the previous page and that it works even when JavaScript is not available.

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

<a href="#" class="govuk-back-link">Back</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 back 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 back link component. If html is provided, the text argument will be ignored.
href string Required. The value of the link href attribute.
classes string Classes to add to the anchor tag.
attributes object HTML attributes (for example data attributes) to add to the anchor tag.
{% from "back-link/macro.njk" import govukBackLink %}

{{ govukBackLink({
  text: "Back",
  href: "#"
}) }}

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 ‘Back link’ on GitHub