Form contrast needs to hold up as people read instructions, move keyboard focus, enter information, and correct mistakes. A field that looks clear in its default light theme may become difficult to use in dark mode—or lose its most important visual cues only after an error appears.
The useful question is not simply “Does this palette pass?” It is: Can someone perceive the information they need at each step of the task?
This walkthrough follows a hypothetical broken-link reporting form through the same task in light and dark modes. The form asks for a page URL and a short description. Its labels, layout, and purpose remain unchanged; only the theme and interaction state change.
Which contrast check applies?
Several WCAG requirements meet inside a form, but they answer different questions. Text readability, control identification, visible focus, and the meaning of color should not be treated as one interchangeable check.
- Text contrast: can the words be distinguished from their background?
-
WCAG 2.2 SC 1.4.3, Contrast (Minimum), requires at least 4.5:1 for ordinary text at Level AA. Qualifying large text requires at least 3:1: generally 18 point, or 14 point bold—approximately 24 CSS pixels, or 18.67 CSS pixels bold. Labels, helper text, entered values, and error messages normally need the ordinary-text threshold.
- Non-text contrast: can the necessary control or state information be identified?
-
SC 1.4.11, Non-text Contrast, requires at least 3:1 against adjacent colors for visual information necessary to identify applicable user interface components and their states. A field boundary or custom focus ring may provide that information. Not every decorative border needs to meet this requirement, and a border is not mandatory when other sufficient visual information identifies the control.
- Visible focus: can a keyboard user see where they are?
-
SC 2.4.7, Focus Visible, requires a mode of operation in which keyboard focus is visible. A contrast measurement helps evaluate a custom indicator, but it does not establish that the indicator actually appears, remains unclipped, or can be found during navigation.
- Use of color: does the meaning survive without distinguishing colors?
-
SC 1.4.1, Use of Color, prevents color from being the only visual means of conveying information. A red border alone does not adequately explain that a field contains an error. A visible message can identify the problem and describe a correction.
These requirements have exceptions and conditions. For example, inactive controls have contrast exceptions under SC 1.4.3 and SC 1.4.11. That does not make faint text a good default, and a read-only field is not automatically an inactive control.
For the walkthrough, keep the comparisons straightforward: ordinary-sized text, active controls, solid backgrounds, and author-defined focus styling.
Set up the same form in two themes
The hypothetical form contains:
- a visible “Page URL” label;
- a persistent instruction: “Paste the full page address, including https://.”;
- a URL input;
- a labeled description field; and
- a “Report broken link” button.
Use solid white, #FFFFFF, as the light form surface and near-black, #18181B, as the dark form surface. For this fixture, the input background matches the surrounding form surface. That keeps the backgrounds in the following comparisons explicit.
The person reads the URL instruction, tabs into the field, enters an incomplete address, and submits. Validation then asks for a complete address. The person finds the feedback, corrects the value, and continues.
The ratios below describe the specified opaque sRGB color pairs. They are rounded for reading; compare unrounded results with WCAG thresholds. A result below 4.5:1 does not pass because its displayed value rounds up to 4.5.
These are illustrative comparisons, not a test report for a deployed form. Opacity, gradients, background images, browser styling, and different surrounding surfaces can change what needs measuring.
Step 1: read the helper text
Before entering anything, the person needs to understand what kind of address the form expects. The instruction is supporting text, but its role is functional: it may prevent an unsuccessful submission.
A common failure is to make supporting text so visually quiet that it becomes difficult to read. Reusing that color in another theme can make the problem worse.
| Theme and background | Before | After |
|---|---|---|
| Light: #FFFFFF | #A1A1AA — 2.56:1 | #52525B — 7.73:1 |
| Dark: #18181B | #52525B — 2.29:1 | #D4D4D8 — 11.99:1 |
Both “before” pairs fall below the 4.5:1 requirement for ordinary text. Both replacements exceed it. Notice that #52525B works well on white but poorly on the dark surface. A color does not have an accessible contrast ratio by itself; the relationship between colors is what matters.
Keep the instruction visible while the person types. Moving it into a placeholder would introduce another problem: the guidance would disappear as soon as an entered value replaced it.
Visual hierarchy does not require unreadable secondary text. Spacing, placement, and restrained typography can distinguish an instruction from a label while preserving readable contrast.
The instruction also needs a programmatic relationship with the input. The broader accessible HTML forms guide explains labels and descriptions in more detail. Here, the important distinction is that a proper association does not repair faint visible text, and strong contrast does not create the association. Both need attention.
Step 2: find the focused field
When the person presses Tab, the task changes. They now need to locate the control receiving keyboard input.
In this fixture, a custom outline sits outside the input with an offset. The outline therefore touches the surrounding form surface rather than the field border. Measure that actual relationship.
| Theme and background | Before | After |
|---|---|---|
| Light: #FFFFFF | #D4D4D8 — 1.48:1 | #1D4ED8 — 6.70:1 |
| Dark: #18181B | #3F3F46 — 1.70:1 | #93C5FD — 9.82:1 |
The faint outlines fail the 3:1 adjacent-color comparison for this custom state indicator. The replacements exceed it.
A corresponding CSS pattern could be:
.link-report {
--form-surface: #FFFFFF;
--focus-ring: #1D4ED8;
background-color: var(--form-surface);
}
.link-report[data-theme="dark"] {
--form-surface: #18181B;
--focus-ring: #93C5FD;
}
.link-report input,
.link-report textarea {
background-color: var(--form-surface);
}
.link-report :is(input, textarea, button):focus-visible {
outline: 3px solid var(--focus-ring);
outline-offset: 3px;
}
This is a focus-style excerpt, not a complete form stylesheet. Text, field boundaries, buttons, and their other states still need their own styling and checks.
The outline’s width and offset make it easier to locate in this example. They are not a claim that every focus indicator must use this geometry. WCAG 2.2 also has a separate Level AAA criterion, SC 2.4.13, Focus Appearance, with additional area and contrast-change requirements; it should not be confused with the AA checks described here.
Now tab through the rendered form. Does the ring appear on every relevant control? Is it clipped by a container? Does a sticky header cover the focused field? Does the ring remain distinguishable when the field also has an error?
A passing color pair cannot answer those questions. If the form moves onto a differently colored panel, its focus styling needs another review.
Step 3: understand and correct the error
Suppose the person enters https:// and selects “Report broken link.” Validation rejects the incomplete address.
In the before version, the field border turns red. The person must notice the change, interpret its meaning, and infer a correction. Someone who cannot distinguish the border colors may not perceive the error at all.
In the improved version, retain a visible state cue and add:
Enter a full page address, such as https://urlmd.com/example/.
The message identifies what is missing and gives a usable example. It does not require the person to interpret red as an instruction.
| Theme and background | Example text color | Contrast ratio |
|---|---|---|
| Light: #FFFFFF | #B91C1C | 6.47:1 |
| Dark: #18181B | #FCA5A5 | 9.33:1 |
Both message colors exceed 4.5:1 on their specified backgrounds. These measurements establish text contrast only. If a colored border or icon supplies necessary visual information about the state, evaluate its non-text contrast separately.
Keep the message connected to the field
The following HTML illustrates the field after custom validation has identified the problem:
<label for="report-url">Page URL</label>
<p id="report-url-hint">
Paste the full page address, including https://.
</p>
<input
type="url"
id="report-url"
name="page_url"
value="https://"
required
aria-invalid="true"
aria-describedby="report-url-hint report-url-error"
>
<p id="report-url-error" class="field-error">
Enter a full page address, such as https://urlmd.com/example/.
</p>
The invalid state is exposed programmatically, the instruction and error are associated with the field, and the entered value is preserved. Do not mark every untouched field invalid when the form first loads.
This markup alone does not implement validation or ensure that a newly inserted message will be announced immediately. The submission behavior must make the feedback discoverable—for example, through deliberate focus movement to the invalid field or an error summary, according to the form’s design. Test that behavior with assistive technology rather than assuming the association handles every announcement.
Also distinguish the form’s instructions from browser validation. An input with type="url" provides URL-related behavior, but does not by itself enforce every application rule, such as an HTTPS-only policy. Any such restriction needs appropriate validation and an explanation that matches it.
Check the combined state
The correction happens while the field is both invalid and focused. An error rule must not erase the focus indicator, and a focus rule must not hide the error cue.
In both themes, the before view has a faint focus ring and a red border as the only error cue. The after view keeps the entered value, makes the outer focus ring easier to see, and adds a message that tells the reader how to correct the URL.
Keep the message available long enough for someone to understand and act on it. Preserve their input, allow keyboard correction, and update the invalid state when validation establishes that the problem has been resolved.
Test the rendered task, not only the palette
A practical contrast review combines repeatable measurements with direct interaction. Use the same short task in both themes so differences are easier to identify.
- Read before typing. Check the label, instruction, empty field, and button. Measure text against its actual background.
- Navigate by keyboard. Tab into the URL field, description, and button. Check focus visibility, neighboring colors, clipping, and obstruction.
- Enter a value. Check entered text, the caret’s visibility, and any browser autofill styling that can occur.
- Trigger an error. Submit an incomplete address. Confirm that the message is readable and the error is understandable without color.
- Correct the entry. Check the focused-invalid state, preserved input, and availability of feedback to assistive technology.
- Complete the task. Check any submitting and confirmation states the implementation provides. A form should not become unreadable during the final step.
Use developer tools or a contrast checker to inspect the colors actually applied. When transparency is involved, evaluate the resulting foreground and background rather than treating a source color token as the rendered color.
Automated tools can catch some failures, but they may not visit an error state, open a validation message, or inspect every theme. Explicitly create those states during testing.
Where supported, also inspect the form in forced-colors mode. This is different from an authored dark theme: user-selected system colors can replace parts of the palette. Preserve useful browser behavior and avoid broadly disabling forced-color adjustments just to retain the original appearance.
A ratio is evidence about a defined color relationship, not a complete measure of reading comfort. Font weight, text size, display conditions, and individual vision still matter. Outdoor or glare testing may be useful when it reflects the form’s expected setting.
For the nonvisual parts of the task, see testing accessibility with assistive technology. Contrast review complements that work; neither replaces the other.
Keep contrast intact as the form changes
Record successful pairings by role and context: helper text on the light surface, helper text on the dark surface, focus ring against the outer panel, and error text against the field’s surrounding background. A list of approved hex values without those relationships loses important information.
For a small form, a lightweight regression record can include:
- the theme and surface being tested;
- the state, including combinations such as focused and invalid;
- the relevant foreground and adjacent background colors;
- the measured ratio and applicable requirement; and
- the interaction check that still needs human review.
Revisit those checks when a theme, component, font, background, plugin, or validation behavior changes. This places contrast within accessibility engineering: an ongoing responsibility supported by testing and maintenance, rather than a one-time palette approval.
The central lesson is modest but useful. Check contrast where the information appears, in the state where someone needs it. Read the instruction. Find focus. Trigger the error. Correct the entry. Repeat in the other theme. That sequence produces better evidence than inspecting the form only while it is empty and still.