Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

autocomplete: tell the browser what a field means

Describe field purpose and distinguish shipping, billing and separate autofill sections.

Version: HTML Living Standard

Syntax

<input name="shippingCity" autocomplete="section-order shipping address-level2">

The autocomplete attribute gives a browser autofill information on form controls. It accepts on, off, or an ordered token list describing the expected value. A list can start with a section- group, then shipping or billing, followed by a purpose such as address-level2. These tokens identify meaning; they do not rename the submitted field.

Use valid tokens in the specified order and appropriate to the control. A hidden input only accepts detail tokens, not the general on/off keywords. When a control has no own setting, its form can supply the default. Disabling autofill is not a security boundary or a reliable prohibition on password managers; browser policy and user choices still matter.

The example separates delivery and billing cities but serializes them under their distinct field names. It assigns fixture values directly and does not access a stored profile. The test therefore confirms form serialization and correct grouping markup, not that every browser will fill the same address automatically.

Examples

<!doctype html><meta charset="utf-8">
<form id="order">
<label>Delivery city <input name="shippingCity" autocomplete="section-order shipping address-level2"></label>
<label>Billing city <input name="billingCity" autocomplete="section-order billing address-level2"></label>
</form><output id="result"></output><script>
const form = document.querySelector('#order');
// Fixture values; this example does not access a saved autofill profile.
form.elements.shippingCity.value = 'Paris';
form.elements.billingCity.value = 'Berlin';
document.querySelector('#result').textContent = JSON.stringify(Object.fromEntries(new FormData(form)));
</script>

Result

{"shippingCity":"Paris","billingCity":"Berlin"}

The two cities are supplied by the fixture; no saved addresses or personal browser profile are used.

Sources