A reviewer asks you to put autocomplete="off" on the password input of your site's login form. Why is that usually the wrong call, and what do browsers actually do with it?
answer
- a request, not an instruction
- browsers took the user's side
- the checklist item that changes nothing
- pushes users to short reused secrets
- narrow legitimate use: a single-use value
basics
~20 sMainstream browsers deliberately ignore autocomplete="off" on password fields and still offer to save and fill credentials, so the attribute mostly fails to do what the reviewer wants while making the form worse for people relying on a password manager.
solid answer
~50 sTwo reasons. First, it largely does not work: browsers concluded years ago that honouring `autocomplete="off"` on credential fields fought their own password managers, so they ignore it there and still offer to save and fill. You get the intent of a control without the effect of one — the worst kind of security measure to have on a checklist. Second, even where it is honoured it is counterproductive: blocking the manager pushes people toward short, memorable, reused passwords typed by hand, which is exactly the outcome you were trying to avoid. `autocomplete="off"` has a genuine, narrow use — a value that must never be reused or persisted, such as a one-time transaction code or an answer the user is expected to derive per submission. For "someone might use a shared computer", the real controls are session and sign-out behaviour on your side, not an attribute you hope the browser respects.
go deeper
Know that autocomplete="off" is a request the browser may ignore, and that on login password fields it usually is ignored. Do not add it to a form by default.
Explain the mechanism and the history: browsers ignore it on credential fields because it fought their own password managers, and an unrecognised token is not a supported way around that.
Be able to push back on the review comment with the real tradeoff — suppression drives password reuse — and redirect to session lifetime, sign-out and re-authentication, which are controls you actually own.
Own the policy: decide where suppression is legitimate across the product, write it down so it is not rediscovered per form, and make sure a compliance checklist cannot mandate a markup attribute that changes nothing observable.
## What the attribute asks for `autocomplete="off"` is a request that the browser not remember the value and not pre-fill the field from anything it has stored. It is a request, not an instruction, and the HTML standard is explicit that user agents may ignore it — most pointedly for fields the browser's own credential manager cares about. It can be written per-field, or once on the `<form>` element as the default for the controls inside it. ## Why browsers stopped honouring it on credentials The attribute was widely deployed on login forms during a period when "the browser remembering your password is dangerous" was conventional wisdom. As built-in password managers matured, that use collided with them directly: a site could unilaterally disable the feature browsers were actively encouraging users to adopt. Vendors resolved the collision in the users' favour. On password fields, mainstream browsers now ignore `autocomplete="off"` and continue to offer saving and filling; several extend the same treatment to address and payment autofill, where the user's stored profile is theirs, not the site's, to control. The practical consequence for you is that shipping `autocomplete="off"` on a login form is close to a no-op with a compliance smell: it appears in the markup, satisfies a checklist item, and changes nothing an attacker would notice. ## Why it would be undesirable even if it worked Suppose your users' browser did honour it. What have you achieved? Nobody responds to a form that refuses to fill by inventing a long random password and retyping it from a vault every visit. They respond by choosing something they can retype: shorter, memorable, and reused across sites. The measure trades a local, well-protected credential store for password reuse — a demonstrably worse position. The threat that motivates the request — a shared or unattended machine — is not addressed by the attribute at all. The password was already saved on that device by the browser, from some earlier visit, whether or not this form says `off`. What actually helps sits on your side of the boundary: sensible session lifetimes, a visible sign-out that invalidates the server-side session, re-authentication before sensitive operations, and letting users see and revoke active sessions. ## Where autocomplete="off" is genuinely right The attribute is not useless. It fits fields whose value is meaningful exactly once and would be actively wrong if remembered or replayed: - a one-time transaction authorisation code or a per-transfer confirmation value; - a challenge answer the user must derive fresh each time; - a field where the browser's stored profile would reliably fill the wrong thing — a form that asks for *someone else's* name and address, such as a gift recipient or a dependant, where offering the user's own saved profile is a nuisance rather than a help. That last case is worth care: reach for it only when a grouping token cannot express the situation better. Two distinct addresses in one form are described with `shipping` / `billing` or `section-*` prefixes rather than by switching autofill off. Also note the family relationship: for a code arriving by SMS you generally want `autocomplete="one-time-code"`, not `off`. The token says "this is a single-use code" and enables the platform to surface it, which is both more useful and more accurate than suppression. ## The anti-pattern of the random token A workaround that circulates widely is to defeat autofill by writing a nonsense value — `autocomplete="nope"`, `autocomplete="new-thing-42"` — on the theory that an unrecognised token is not `on`. It is not a supported mechanism. An unrecognised token is simply not a field name, so you fall back to the browser's heuristics; whether anything is suppressed depends on implementation details that change. Code built on that trick breaks quietly on a browser update and leaves a value in the markup that no one can explain. ## How to answer the reviewer Say plainly what the attribute does and does not do, name the narrow cases where it applies, and redirect the concern to controls that live in your system. If the requirement is genuinely "credentials must not persist on this device", the honest answer is that a web form cannot enforce it — that is device management territory. If the requirement is "this specific value must not be replayed", then `autocomplete="off"` on that one field is exactly right, and you should scope it there rather than blanket the form. And if the form is a login, the productive change is the opposite of the request: add `autocomplete="username"` and `autocomplete="current-password"`, so that the manager fills the right boxes and users can afford long generated passwords.
- Is there any field where you would actively defend using autocomplete="off"?Yes — values meaningful exactly once, where remembering them is wrong rather than merely unhelpful: a one-time transaction authorisation code, a per-submission challenge answer, or a field asking for a third party's details where the user's own saved profile would fill the wrong data. Scope it to that field, not the whole form. For an SMS code, prefer `autocomplete="one-time-code"` — it describes the field instead of just suppressing help.
- Some codebases write a nonsense value like autocomplete="nope" to defeat autofill. What is wrong with that?It relies on unspecified behaviour. An unrecognised token simply is not a field name, so the browser falls back to heuristic guessing; whether that suppresses anything depends on implementation details that change between releases. The trick breaks silently on an update and leaves an unexplainable value in the markup. If suppression is genuinely wanted, `off` is the defined way to ask.
- The requirement is that credentials must not persist on shared machines. What actually delivers that?Not markup. The browser's store is outside your control, and any earlier visit may already have saved the password. What you control is session behaviour: short-lived sessions, a sign-out that invalidates server-side state, re-authentication before sensitive actions, and a session list users can revoke. Enforcing "nothing persists on this device" is device-management territory, not something a form attribute can promise.
saying these in an interview costs you the question
- Believes autocomplete="off" reliably disables password managers
- Treats the attribute as a security control
- Uses a random token value to defeat autofill
- Blankets a whole form with off instead of one field
- Says blocking managers makes users choose stronger passwords