Skip to content

VBC-123: placeholder-as-label

warning

Category: ux-dx
Analysis: Regex (whole file)
File types: .html, .js, .ts, .tsx, .astro
Scope: source code only, ignoring anything inside strings and comments
Tags: ux accessibility

What it reports

Using placeholder as the only label at line {line} is bad for accessibility.

Flagged

html
<input
  type="email"
  placeholder="Email"
/>

Not flagged

html
<label for="email">Email</label>
<input id="email" placeholder="you@example.com" />

Pattern

regex
<input\b(?![^>]*(?:aria-label|aria-labelledby|\bid\s*=))[^>]*\bplaceholder\s*=

Released under the MIT License.