---
title: "Address Form"
description: "Collects a shipping or billing address - the fields every browser can autofill, laid out in a grid, with saved addresses to pick from."
slug: "address-form"
---

import { DocPage, PageHeader, SkillPanel, SourceFiles, DocLink, SkillField, SkillText, SkillRow, ApiPill } from "../../lib/components/index";

<DocPage meta={meta}>

<PageHeader slug="address-form" title="Address Form" component="address-form">
  Collects a shipping or billing address - the fields every browser can autofill, laid out in a grid, with saved addresses to pick from. Part of the <DocLink href="website-shop.html">Shop</DocLink> blocks.
</PageHeader>

<SkillPanel component="address-form">
  <SkillField label="Native basis">
<SkillText>A <code>&lt;fieldset&gt;</code> of labelled Inputs with the standard <code>autocomplete</code> tokens in a 6-column grid (<code>data-span</code>), a country Select, a "billing address is the same" Checkbox - or saved addresses as radio cards.</SkillText>
  </SkillField>

  <SkillField label="Built from">
<SkillText><DocLink href="input.html">Input</DocLink>, <DocLink href="select.html">Select</DocLink>, <DocLink href="checkbox.html">Checkbox</DocLink>, <DocLink href="label.html">Label</DocLink>.</SkillText>
  </SkillField>

  <SkillField label="Web Platform APIs">
<SkillRow>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete" title="the browser fills known fields"><code>autocomplete</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fieldset" title="grouped controls with a legend"><code>&lt;fieldset&gt;</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation" title="required, type and pattern - the browser checks the form"><code>Constraint validation</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/:has" title="parent styles react to a checked input or a state inside"><code>:has()</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/address" title="contact information"><code>&lt;address&gt;</code></ApiPill>
    <ApiPill href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_containment/Container_queries" title="the layout follows the block width, not the viewport"><code>Container queries</code></ApiPill>
  </SkillRow>
  </SkillField>

  <SkillField label="Classes">
<SkillRow>
    <code>.mk-address-form</code>
    <code>.mk-address-form-grid</code>
    <code>.mk-address-form-field</code>
    <code>.mk-address-form-same</code>
    <code>.mk-address-form-saved</code>
    <code>.mk-address-form-option</code>
    <code>.mk-address-form-add</code>
  </SkillRow>
  </SkillField>

  <SkillField label="Data attributes">
<SkillText><code>data-span="2|3|4|6"</code> on fields (of 6 columns); <code>.mk-address-form-saved</code> for saved addresses.</SkillText>
  </SkillField>
</SkillPanel>

```html example label="Default" hint="The standard autocomplete tokens on every field - one tap fills it all - in a 6-column grid (data-span) that collapses to one column when narrow. Country first; optional fields say so." previewStyle="align-items:stretch;"
<fieldset class="mk-address-form">
  <legend>Shipping address</legend>
  <div class="mk-address-form-grid">
    <div class="mk-address-form-field"
      ><label class="label" for="ad-country">Country / region</label
      ><select class="select" id="ad-country" name="country" autocomplete="country"
        ><option value="PT">Portugal</option
        ><option value="DE">Germany</option
        ><option value="FR">France</option></select
      ></div
    >
    <div class="mk-address-form-field" data-span="4"
      ><label class="label" for="ad-name">Full name</label
      ><input class="input" id="ad-name" name="name" autocomplete="shipping name" required
    /></div>
    <div class="mk-address-form-field" data-span="2"
      ><label class="label" for="ad-org">Company <small>(optional)</small></label
      ><input class="input" id="ad-org" name="organization" autocomplete="shipping organization"
    /></div>
    <div class="mk-address-form-field"
      ><label class="label" for="ad-l1">Street and number</label
      ><input class="input" id="ad-l1" name="address1" autocomplete="shipping address-line1" required
    /></div>
    <div class="mk-address-form-field"
      ><label class="label" for="ad-l2">Apartment, floor <small>(optional)</small></label
      ><input class="input" id="ad-l2" name="address2" autocomplete="shipping address-line2"
    /></div>
    <div class="mk-address-form-field" data-span="2"
      ><label class="label" for="ad-zip">Postal code</label
      ><input class="input" id="ad-zip" name="postal" autocomplete="shipping postal-code" required
    /></div>
    <div class="mk-address-form-field" data-span="4"
      ><label class="label" for="ad-city">City</label
      ><input class="input" id="ad-city" name="city" autocomplete="shipping address-level2" required
    /></div>
    <div class="mk-address-form-field" data-span="3"
      ><label class="label" for="ad-tel">Phone <small>(for the courier)</small></label
      ><input class="input" id="ad-tel" type="tel" name="tel" autocomplete="shipping tel" inputmode="tel"
    /></div>
    <div class="mk-address-form-field" data-span="3"
      ><label class="label" for="ad-mail">Email</label
      ><input class="input" id="ad-mail" type="email" name="email" autocomplete="email" required
    /></div>
  </div>
  <div class="mk-address-form-same"
    ><input class="checkbox" type="checkbox" id="ad-same" name="billing-same" checked /><label for="ad-same"
      >Billing address is the same</label
    ></div
  >
</fieldset>
```

```html example label="Saved addresses" hint=".mk-address-form-saved: saved addresses as radio cards (:has(:checked) outlines the choice), each with an edit link, and a way to add a new one." previewStyle="align-items:stretch;"
<fieldset class="mk-address-form" style="max-width: 32rem">
  <legend>Deliver to</legend>
  <div class="mk-address-form-saved">
    <label class="mk-address-form-option"
      ><input class="radio" type="radio" name="addr" value="home" checked /><strong>Home</strong><a href="#">Edit</a
      ><address>Anna Silva<br />Rua da Prata 120, 2º<br />1100-420 Lisboa, Portugal</address></label
    >
    <label class="mk-address-form-option"
      ><input class="radio" type="radio" name="addr" value="office" /><strong>Office</strong><a href="#">Edit</a
      ><address>Anna Silva, Acme<br />Torstraße 45<br />10119 Berlin, Germany</address></label
    >
  </div>
  <a class="mk-address-form-add" href="#"><i data-lucide="plus"></i> Add a new address</a>
</fieldset>
```

<SourceFiles component="address-form" section="css" />

</DocPage>
