Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Visual Example

The placeholder is text that appears inside a form control by default. In the below examples it’s the word “Search” and dashes.

Compliant Example:

...

Non-Compliant Example:

...

Acceptance Criteria

...

In this case you would need to add either a visible or an invisible form label for screen reader users.

One issue with the placeholder is that it disappears once information has been entered into the field, making it more difficult for users to make corrections.

Don’t place important form instructions in the placeholder.

Ensure that important form instructions are available even when the user fills the data.

The placeholder attribute is announced by most screen reader and browser combinations.

Don’t place characters, such as dashes (-------) ” or parenthesis ”( )” in the placeholder. It

Those characters will be announced by the screen readers reader as follows:

“dash, dash, dash, dash, dash” and “close parent, open parent”

Provide form instructions either above or below the form control.

As a screen reader and keyboard only user I should:

  • be provided with a form label

  • be able to use the TAB key on the keyboard to access the form control

  • be able to access important form instructions

As a screen reader user I should:

  • be able to explicitly associate the text label with the form control

...

  • the screen reader should announce the form label and then the text in the placeholderif the text in the placeholder is the same as the form label the placeholder will not be announced by the screen reader

  • the screen reader should announce the form instructions

  • the screen reader should NOT announce dashes or any other characters

...

Markup and Code

 

Code Block
<form id="sfgov-search-form" role="search" novalidate="novalidate" method="post">
  <form>
  <div>
	<label for="searchphone-inputnumber">Search<>Phone Number</label>
	<input id="serchphone-inputnumber" type="text" aria-describedby="phoneinstructions">
	<p placeholderid="Search" />phoneinstructions">Enter your 10 digit phone number including area code.</p>
  </div>   
</form>

View markup on github