Navigation - Back link

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

Open this default back link example in new window
Copy default back link code
<div class="hse-back-link">
  <a class="hse-back-link__link" href="#">
    <svg class="hse-icon hse-icon__chevron-left" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true">
      <path d="M8.496 12a1 1 0 0 1 .29-.71l5-5a1.004 1.004 0 0 1 1.42 1.42l-4.3 4.29 4.3 4.29a1.004 1.004 0 0 1-1.42 1.42l-5-5a1 1 0 0 1-.29-.71Z" />
    </svg>
    Go back</a>
</div>
Close default back link code
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.

Nunjucks arguments for default back link
Name Type Required Description
Name text Type string Required false Description Text to use within the back link component. If `html` is provided, the `text` argument will be ignored. Defaults to "Back".
Name html Type string Required false Description HTML to use within the back link component. If `html` is provided, the `text` argument will be ignored. Defaults to "Back".
Name href Type string Required false Description The value of the link href attribute.
Name classes Type string Required false Description Classes to add to the container.
Name attributes Type object Required false Description HTML attributes (for example data attributes) to add to the tag.
Name element Type string Required false Description Which html element to use to render the back link - `button` or `a`. If not provided, defaults to `a`.
Copy default back link code
{% from 'back-link/macro.njk' import backLink %}

{{ backLink({
  "href": "#",
  "text": "Go back"
}) }}
Close default back link code

When to use a back link

We only use back links on transactional services or multi-page forms, including question pages. Question pages are pages where a user is asked to submit some information. For example, where they live.

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

When not to use a back link

Do not use a back link on a content page, like a health information page.

Do not use a back link with breadcrumbs.

How to use back links

Use a back link at the top of a page, below the header. Do not put it close to other links or buttons where it might distract users from what they need to do.

Make sure the text used in the link describes the action, for example "Go back". Carry out research with users to find the words that help them the most.

The link should take users back to the page they were on in the state they last saw it.

You can render the back link as a button element if necessary in order to post form data back to the previous page.

Open this button back link example in new window
Copy button back link code
<div class="hse-back-link">
  <a class="hse-back-link__link" href="#">
    <svg class="hse-icon hse-icon__chevron-left" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true">
      <path d="M8.496 12a1 1 0 0 1 .29-.71l5-5a1.004 1.004 0 0 1 1.42 1.42l-4.3 4.29 4.3 4.29a1.004 1.004 0 0 1-1.42 1.42l-5-5a1 1 0 0 1-.29-.71Z" />
    </svg>
    Go back</a>
</div>
Close button back link code
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.

Nunjucks arguments for button back link
Name Type Required Description
Name text Type string Required false Description Text to use within the back link component. If `html` is provided, the `text` argument will be ignored. Defaults to "Back".
Name html Type string Required false Description HTML to use within the back link component. If `html` is provided, the `text` argument will be ignored. Defaults to "Back".
Name href Type string Required false Description The value of the link href attribute.
Name classes Type string Required false Description Classes to add to the container.
Name attributes Type object Required false Description HTML attributes (for example data attributes) to add to the tag.
Name element Type string Required false Description Which html element to use to render the back link - `button` or `a`. If not provided, defaults to `a`.
Copy button back link code
{% from 'back-link/macro.njk' import backLink %}

{{ backLink({
  "text": "Go back",
  "element": "button"
}) }}
Close button back link code

Interactive states for a back link

There are 3 interactive states:

  • default
  • hover
  • focus

Accessibility

When you're considering where to put a back link on a page, think about people who use a screen reader.

Make sure the text you use describes the action. Do not rely on "Go back". It might not reflect what users expect.

Updated: August 2023