CKTIS / CSS
:autofill — a browser-autofilled input
The :autofill pseudo-class selects input elements filled automatically by the browser until the user changes their values. It lets you highlight that state; it does not simply mean that a field contains text.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
input:autofill { outline: 3px solid #006b4f; }:autofill is a state pseudo-class with no arguments. The selector input:autofill matches an input that the browser has filled automatically and the user has not subsequently edited. Once the user edits it, the field stops matching.
The autocomplete attribute can participate in autofilling, but it is neither a matching requirement nor a guarantee that filling will occur. Typing text, supplying an initial value, or assigning a value through script is not browser autofill. HTML also defines the compatibility pseudo-class :-webkit-autofill for the same state; use the standard name :autofill in new code.
The example adds a green outline when the field is autofilled. Testing requires saved data and actual use of the browser's autofill mechanism, so it is not fully deterministic. If the browser offers no autofill option, do not treat that as evidence that the selector is broken.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Autofill selector demo</title>
<style>
input { padding: 0.5rem; }
input:autofill {
outline: 3px solid #006b4f;
outline-offset: 3px;
}
</style>
<form>
<label for="email">Email</label>
<input id="email" name="email" type="email" autocomplete="email">
<button type="submit">Submit</button>
</form>
</html>Result
When the browser autofills the email input, a green outline appears. After the user edits its value, the autofill outline disappears. Typing an email manually does not activate this rule.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.