Tailwind CSS fix

Before and after

Broken — before
<!-- Broken Tailwind inline newsletter form: placeholder-only input -->
<form class="flex max-w-md gap-2">
  <input
    type="email"
    placeholder="Enter your work email"
    class="flex-1 rounded-md border border-slate-300 px-3 py-2 text-sm text-slate-900"
  />
  <button type="submit" class="rounded-md bg-slate-900 px-4 py-2 text-sm font-semibold text-white">
    Join
  </button>
</form>
Fixed — after
<!-- Fixed Tailwind form: visible accessible label + high-contrast border & focus ring -->
<form class="max-w-md space-y-1.5">
  <label for="waitlist-email" class="block text-sm font-medium text-slate-900">
    Work email
  </label>
  <div class="flex gap-2">
    <input
      id="waitlist-email"
      name="email"
      type="email"
      autocomplete="email"
      placeholder="alex@studio.com"
      class="flex-1 rounded-md border border-slate-400 px-3 py-2 text-sm text-slate-900 placeholder:text-slate-500 focus:border-sky-700 focus:outline-2 focus:outline-offset-1 focus:outline-sky-700"
    />
    <button
      type="submit"
      class="rounded-md bg-slate-900 px-4 py-2 text-sm font-semibold text-white hover:bg-slate-800"
    >
      Join
    </button>
  </div>
</form>
Live preview

Fixed vs. broken example

Passes label
Accessibility tree: role="textbox", accessible name="Work email address" (programmatically bound via <label for="demo-work-email">)

Click directly on the "Work email address" label in the fixed preview: native browsers expand the hit target and immediately move focus into the input.

Automated test

Playwright + axe-core check

tests/a11y-label.spec.ts
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";

test("Tailwind waitlist form input passes axe-core label", async ({ page }) => {
  await page.goto("/");
  await expect(page.getByLabel("Work email")).toBeVisible();
  const results = await new AxeBuilder({ page })
    .withRules(["label"])
    .analyze();
  expect(results.violations).toEqual([]);
});

Template deduplication tip

A Tailwind waitlist or footer subscribe form embedded across landing and blog routes produces repeated label errors. A11yDrift merges every occurrence under one component fingerprint.

Screen readers

What NVDA and VoiceOver announce

Placeholder-only inputs lose their hint the moment a user starts typing, cannot be focused by clicking a visible label target, and leave screen-reader and cognitive-disability users guessing which data belongs in each field during checkout or signup.

NVDA (Windows)

Broken

"edit, has auto complete, blank" (no field purpose announced)


Fixed

"Work email address, edit, has auto complete, blank"

VoiceOver (macOS / iOS)

Broken

"edit text, Work email address" (inconsistent placeholder fallback that disappears once filled)


Fixed

"Work email address, edit text"

Common questions

Do Tailwind peer floating labels pass WCAG 2.2 AA?
Yes, as long as the floating element is a real <label for='...'> (not a <span>), maintains >= 4.5:1 contrast in both resting and floated states, and never overlaps typed text at 200% zoom.
What border color should Tailwind inputs use to meet WCAG 1.4.11 Non-text Contrast?
Default border-slate-200 or border-gray-300 falls below 3:1 against #ffffff. Use border-slate-400 or border-slate-500 (at least 3:1 boundary contrast) so low-vision users can easily locate input edges.
Should checkboxes and radio buttons in Tailwind also use <label for>?
Always. Pair each checkbox/radio with a <label for> and wrap related radio groups in a <fieldset> with a <legend> so screen readers announce both the group prompt and option name.