--- url: "https://design-system.service.gov.uk/patterns/addresses/" titulek: "Addresses – GOV.UK Design System" h1: "Ask users for Addresses" popis: "Help users provide an address" jazyk: "en" kanonicka: "https://design-system.service.gov.uk/patterns/addresses/" drobecky: ["Home", "Patterns"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 01:22:21" znaku: 13088 slov: 1829 kodovani: "utf-8" sha256: "dbf64262db1b8e792c6b94add454354e0fb4956a86011f47998582230ece5cd3" --- # Ask users for Addresses This guidance is for government teams that build online services. [To find information and services for the public, go to GOV.UK](https://www.gov.uk/). Help users provide an address using one of the following: - Multiple text inputs - Address lookup - Textarea ## Multiple text inputs - HTML - Nunjucks HTML ```
``` Nunjucks ``` {% from "govuk/components/input/macro.njk" import govukInput %} {% from "govuk/components/fieldset/macro.njk" import govukFieldset %} {% call govukFieldset({ legend: { text: "What is your address?", classes: "govuk-fieldset__legend--l", isPageHeading: true } }) %} {{ govukInput({ label: { text: "Address line 1" }, id: "address-line-1", name: "addressLine1", autocomplete: "address-line1" }) }} {{ govukInput({ label: { text: "Address line 2 (optional)" }, id: "address-line-2", name: "addressLine2", autocomplete: "address-line2" }) }} {{ govukInput({ label: { text: "Town or city" }, classes: "govuk-!-width-two-thirds", id: "address-town", name: "addressTown", autocomplete: "address-level2" }) }} {{ govukInput({ label: { text: "County (optional)" }, classes: "govuk-!-width-two-thirds", id: "address-county", name: "addressCounty" }) }} {{ govukInput({ label: { text: "Postcode" }, classes: "govuk-input--width-10", id: "address-postcode", name: "addressPostcode", autocomplete: "postal-code" }) }} {% endcall %} ``` ### When to use multiple text inputs Only use multiple text inputs when you know which countries the addresses will come from and can find a format that supports them all. This can be difficult to know if you’re asking for addresses outside of the UK. Using multiple text inputs means: - you can easily extract and use specific parts of an address - you can give help for individual text inputs - you can validate each part of the address separately - users can complete the form using their browser’s autocomplete function The disadvantages of using multiple text inputs are that: - it’s hard to find a single format that works for all addresses - there’s no guarantee that users will use the text inputs the way you think they will - users cannot easily paste addresses from their clipboards ### How multiple text inputs work If you use multiple text inputs, you should: - only make individual text inputs mandatory if you really need the information - make the text inputs the appropriate length for the content – it helps people understand the form, for example, make postcode text inputs shorter than street text inputs - let users enter postcodes in different formats Make sure there are enough text inputs to accommodate longer addresses if you know your users will need them. For example, allow users to include a company name or flat number. Make it optional for users to enter their county (such as Berkshire or Cumbria). It’s not part of a correct UK address, according to Royal Mail, and it’s not used to deliver post. Remove the county field if you’re sure your users will not need it, and your service will not use it. #### Use the autocomplete attribute on multiple address fields Use the `autocomplete` attribute on each individual address field to help users enter their address more quickly. This lets you specify each input’s purpose so browsers can autofill the information on a user’s behalf if they’ve entered it previously. [Check which input purpose to use](https://www.w3.org/TR/WCAG22/#input-purposes) for each field. In production, you’ll need to do this to meet [WCAG 2.2 success criterion 1.3.5 Identify input purpose](https://www.w3.org/WAI/WCAG22/Understanding/identify-input-purpose.html). You will not normally need to use the `autocomplete` attribute in prototypes, as users will not generally be using their own devices. #### Error messages Error messages should be styled like this: - HTML - Nunjucks HTML ``` ``` Nunjucks ``` {% from "govuk/components/input/macro.njk" import govukInput %} {% from "govuk/components/fieldset/macro.njk" import govukFieldset %} {% call govukFieldset({ legend: { text: "What is your address?", classes: "govuk-fieldset__legend--l", isPageHeading: true } }) %} {{ govukInput({ label: { text: 'Address line 1' }, id: "address-line-1", name: "addressLine1", errorMessage: { text: "Enter address line 1, typically the building and street" }, autocomplete: "address-line1" }) }} {{ govukInput({ label: { text: 'Address line 2 (optional)' }, id: "address-line-2", name: "addressLine2", autocomplete: "address-line2" }) }} {{ govukInput({ label: { text: "Town or city" }, classes: "govuk-!-width-two-thirds", id: "address-town", name: "addressTown", errorMessage: { text: "Enter town or city" }, autocomplete: "address-level2" }) }} {{ govukInput({ label: { text: "County (optional)" }, classes: "govuk-!-width-two-thirds", id: "address-county", name: "addressCounty" }) }} {{ govukInput({ label: { text: "Postcode" }, classes: "govuk-input--width-10", id: "address-postcode", name: "addressPostcode", errorMessage: { text: "Enter postcode" }, autocomplete: "postal-code" }) }} {% endcall %} ``` If a postcode entered is not a real postcode, use a message like this: - HTML - Nunjucks HTML ```