Content · Web Development · HTML

HTML address-line2 Autocomplete Token: Reference and Examples

Learn how to use autocomplete="address-line2" in HTML forms with readable code, privacy notes and beginner tips.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

Have you ever started typing into a form and had your browser suggest a saved value? HTML can help the browser decide which value belongs in which field. The autocomplete token address-line2 is used for secondary street-address details.

What address-line2 tells the browser


Secondary street-address details.

This is a hint, not an instruction to fill a value automatically. Browsers and password managers consider settings, saved data, permissions and other signals before offering suggestions.

Example form field


<form action="/example" method="post">
    <label for="detail-field">Apartment or unit</label>
    <input id="detail-field" name="detail" type="text" autocomplete="address-line2">
    <button type="submit">Continue</button>
</form>

Understanding the example


The autocomplete="address-line2" attribute labels this field for autofill. Its visible <label> still tells people what to type, and its name attribute determines the key sent when a form is submitted.

Usually optional: apartment, suite, building, or similar.

Address formats differ widely by country. Keep optional fields truly optional and avoid strict assumptions about postcode length, district names or address ordering.

Try it yourself


Save the example as an HTML file, and test the field with browser autofill enabled. Inspect the autocomplete value and compare it with the field label. Browser behavior depends on available saved information, so a missing suggestion is not necessarily an HTML mistake.

Common Beginner Mistakes


  • Usually optional: apartment, suite, building, or similar.
  • Leaving out the visible label because the browser might autofill the field.
  • Treating autofill suggestions as verified or safe data.

Key Takeaways


  • address-line2 describes secondary street-address details.
  • Usually optional: apartment, suite, building, or similar.
  • Autocomplete helps users; it does not replace labeling, accessibility or validation.
Share this resourceSend this page to someone who may find it useful.