Despite autocomplete
being a pretty well defined part of the HTML5 spec, Chrome has flip-flopped on how they use the autocomplete
property. Originally honoring autocomplete="off"
(2013), they then decided that developers must be using it wrong and the browser should just ignore it.
This doesn't mean there aren't very valid cases where you don't want the browser autofilling data (e.g. on CRM systems), but by and large, we see those as the minority cases. And as a result, we started ignoring autocomplete=off for Chrome Autofill data.
(Source: Chromium bug from 2015 marked as WontFix)
According to the Priority of Constituencies:
In case of conflict, consider users over authors over implementors over specifiers over theoretical purity. In other words costs or difficulties to the user should be given more weight than costs to authors; which in turn should be given more weight than costs to implementors...
...Which leaves us developers in the unfortunate spot of finding a work-around. This article from MDN outlines the current state well, and offers this solution of setting autocomplete
to new-password
:
If an author would like to prevent the autofilling of password fields in user management pages where a user can specify a new password for someone other than themself, autocomplete="new-password" should be specified, though support for this has not been implemented in all browsers yet.
I'm not sure how long this will remain valid, but for now (tested in Chrome 53 in September 2016) this is the easiest solution:
<input type="password" name="someName" autocomplete="new-password" />
Edit: Note: This has the side-effect of asking the user to save the password, possibly overwriting an existing password. So while it does "prevent the autofilling of password fields" it does not remove the element from the autocomplete mess altogether.
Edit: Updated Info: Newer versions of Chrome once again respect the autocomplete=off
attribute, as Alexander Abakumov pointed out in his answer. He had it working for Chrome 68, works on Chrome 70 for me.