Form elements
–
Error summary
Include an error summary at the top of a page to summarise any mistakes a user has made.
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. Deprecated options are marked as "Deprecated".
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.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the error summary. |
|
title |
string |
Required.
If titleHtml is set, this is not required. Text to use for the heading of the error summary block. If titleHtml is provided, titleText will be ignored.
|
|
title |
string |
Required.
If titleText is set, this is not required. HTML to use for the heading of the error summary block. If titleHtml is provided, titleText will be ignored.
|
|
description |
string |
Text to use for the description of the errors. If you set descriptionHtml, the component will ignore descriptionText.
|
|
description |
string |
HTML to use for the description of the errors. If you set this option, the component will ignore descriptionText.
|
| caller | nunjucks-block |
Not strictly a parameter but Nunjucks code convention. Using a call block enables you to call a macro with all the text inside the tag. This is helpful if you want to pass a lot of content into a macro. To use it, you will need to wrap the entire error summary component in a call block.
|
|
error |
array |
A list of errors to include in the error summary.
See macro options for error |
|
disable |
boolean | Prevent moving focus to the error summary when the page loads. |
| classes | string | Classes to add to the error-summary container. |
| attributes | object | HTML attributes (for example data attributes) to add to the error-summary container. |
| Name | Type | Description |
|---|---|---|
| href | string |
The href attribute for the error link item. If provided item will be an anchor.
|
| text | string |
Required.
If html is set, this is not required. Text for the error link item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML for the error link item. If html is provided, the text option will be ignored.
|
| attributes | object | HTML attributes (for example data attributes) to add to the error link anchor. |
When to use an error summary
When a user makes a mistake, you must show an error summary at the top of the page as well as an error message next to each answer that contains an error.
Always show an error summary when there is a validation error, even if there’s only 1 mistake.
How to use an error summary
You must:
- add "Error: " to the beginning of the
<title>so screen readers read it out as soon as possible - show an error summary at the top of a page
- move the keyboard focus to the error summary (the NHS.UK frontend JavaScript will do this for you)
- include the heading "There is a problem"
- link to each of the answers that have validation errors
- show the same error messages next to the inputs with errors
Follow GOV.UK Design System guidance on writing good error messages.
Linking from the error summary to each answer
You must link the errors in the error summary to the answer they relate to.
For questions that require a user to answer using a single field, like a select, textarea or text input, link to the field.
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. Deprecated options are marked as "Deprecated".
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.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the error summary. |
|
title |
string |
Required.
If titleHtml is set, this is not required. Text to use for the heading of the error summary block. If titleHtml is provided, titleText will be ignored.
|
|
title |
string |
Required.
If titleText is set, this is not required. HTML to use for the heading of the error summary block. If titleHtml is provided, titleText will be ignored.
|
|
description |
string |
Text to use for the description of the errors. If you set descriptionHtml, the component will ignore descriptionText.
|
|
description |
string |
HTML to use for the description of the errors. If you set this option, the component will ignore descriptionText.
|
| caller | nunjucks-block |
Not strictly a parameter but Nunjucks code convention. Using a call block enables you to call a macro with all the text inside the tag. This is helpful if you want to pass a lot of content into a macro. To use it, you will need to wrap the entire error summary component in a call block.
|
|
error |
array |
A list of errors to include in the error summary.
See macro options for error |
|
disable |
boolean | Prevent moving focus to the error summary when the page loads. |
| classes | string | Classes to add to the error-summary container. |
| attributes | object | HTML attributes (for example data attributes) to add to the error-summary container. |
| Name | Type | Description |
|---|---|---|
| href | string |
The href attribute for the error link item. If provided item will be an anchor.
|
| text | string |
Required.
If html is set, this is not required. Text for the error link item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML for the error link item. If html is provided, the text option will be ignored.
|
| attributes | object | HTML attributes (for example data attributes) to add to the error link anchor. |
When a user has to enter their answer into multiple fields, such as the day, month and year fields in the date input component, link to the 1st field that contains an error.
If you do not know which field contains an error, link to the 1st field.
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. Deprecated options are marked as "Deprecated".
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.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the error summary. |
|
title |
string |
Required.
If titleHtml is set, this is not required. Text to use for the heading of the error summary block. If titleHtml is provided, titleText will be ignored.
|
|
title |
string |
Required.
If titleText is set, this is not required. HTML to use for the heading of the error summary block. If titleHtml is provided, titleText will be ignored.
|
|
description |
string |
Text to use for the description of the errors. If you set descriptionHtml, the component will ignore descriptionText.
|
|
description |
string |
HTML to use for the description of the errors. If you set this option, the component will ignore descriptionText.
|
| caller | nunjucks-block |
Not strictly a parameter but Nunjucks code convention. Using a call block enables you to call a macro with all the text inside the tag. This is helpful if you want to pass a lot of content into a macro. To use it, you will need to wrap the entire error summary component in a call block.
|
|
error |
array |
A list of errors to include in the error summary.
See macro options for error |
|
disable |
boolean | Prevent moving focus to the error summary when the page loads. |
| classes | string | Classes to add to the error-summary container. |
| attributes | object | HTML attributes (for example data attributes) to add to the error-summary container. |
| Name | Type | Description |
|---|---|---|
| href | string |
The href attribute for the error link item. If provided item will be an anchor.
|
| text | string |
Required.
If html is set, this is not required. Text for the error link item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML for the error link item. If html is provided, the text option will be ignored.
|
| attributes | object | HTML attributes (for example data attributes) to add to the error link anchor. |
For questions that require a user to select one or more options from a list using radios or checkboxes, link to the 1st radio or checkbox.
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. Deprecated options are marked as "Deprecated".
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.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the error summary. |
|
title |
string |
Required.
If titleHtml is set, this is not required. Text to use for the heading of the error summary block. If titleHtml is provided, titleText will be ignored.
|
|
title |
string |
Required.
If titleText is set, this is not required. HTML to use for the heading of the error summary block. If titleHtml is provided, titleText will be ignored.
|
|
description |
string |
Text to use for the description of the errors. If you set descriptionHtml, the component will ignore descriptionText.
|
|
description |
string |
HTML to use for the description of the errors. If you set this option, the component will ignore descriptionText.
|
| caller | nunjucks-block |
Not strictly a parameter but Nunjucks code convention. Using a call block enables you to call a macro with all the text inside the tag. This is helpful if you want to pass a lot of content into a macro. To use it, you will need to wrap the entire error summary component in a call block.
|
|
error |
array |
A list of errors to include in the error summary.
See macro options for error |
|
disable |
boolean | Prevent moving focus to the error summary when the page loads. |
| classes | string | Classes to add to the error-summary container. |
| attributes | object | HTML attributes (for example data attributes) to add to the error-summary container. |
| Name | Type | Description |
|---|---|---|
| href | string |
The href attribute for the error link item. If provided item will be an anchor.
|
| text | string |
Required.
If html is set, this is not required. Text for the error link item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML for the error link item. If html is provided, the text option will be ignored.
|
| attributes | object | HTML attributes (for example data attributes) to add to the error link anchor. |
Where to put the error summary
Put the error summary at the top of the main container. If your page includes breadcrumbs or a back link, place it below these, but above the <h1>.
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. Deprecated options are marked as "Deprecated".
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.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the error summary. |
|
title |
string |
Required.
If titleHtml is set, this is not required. Text to use for the heading of the error summary block. If titleHtml is provided, titleText will be ignored.
|
|
title |
string |
Required.
If titleText is set, this is not required. HTML to use for the heading of the error summary block. If titleHtml is provided, titleText will be ignored.
|
|
description |
string |
Text to use for the description of the errors. If you set descriptionHtml, the component will ignore descriptionText.
|
|
description |
string |
HTML to use for the description of the errors. If you set this option, the component will ignore descriptionText.
|
| caller | nunjucks-block |
Not strictly a parameter but Nunjucks code convention. Using a call block enables you to call a macro with all the text inside the tag. This is helpful if you want to pass a lot of content into a macro. To use it, you will need to wrap the entire error summary component in a call block.
|
|
error |
array |
A list of errors to include in the error summary.
See macro options for error |
|
disable |
boolean | Prevent moving focus to the error summary when the page loads. |
| classes | string | Classes to add to the error-summary container. |
| attributes | object | HTML attributes (for example data attributes) to add to the error-summary container. |
| Name | Type | Description |
|---|---|---|
| href | string |
The href attribute for the error link item. If provided item will be an anchor.
|
| text | string |
Required.
If html is set, this is not required. Text for the error link item. If html is provided, the text option will be ignored.
|
| html | string |
Required.
If text is set, this is not required. HTML for the error link item. If html is provided, the text option will be ignored.
|
| attributes | object | HTML attributes (for example data attributes) to add to the error link anchor. |
Research
GOV.UK research on error summaries showed users:
- understood what went wrong
- knew how to fix the problem
- were able to recover from the error
Help us improve this guidance
Share insights or feedback and take part in the discussion. We use GitHub as a collaboration space. All the information on it is open to the public.
Feed back or share insights on GitHubRead more about how to feed back or share insights.
If you have any questions, get in touch with the service manual team.
Updated: November 2025