MultiformeIngegno
MultiformeIngegno

Reputation: 7059

Why isn't alt a valid attribute for <input>?

alt="" attribute isn't valid on <input> tags. Why this choice?

HTML5 Specification

I know that alt is meant to provide an alternative content if "main" content is not available, and since the input tag is there to actually input something an alternative text wouldn't be useful, but nowadays alt attributes are mostly used for accessibility purposes! If no alt or name or placeholder are present the only attribute to decipher the nature of the element would be the type. But what if multiple inputs with same type are present?

What do you thing?

Upvotes: 0

Views: 266

Answers (1)

Jaime Gomez
Jaime Gomez

Reputation: 7067

label is actually used for this purpose, for example:

<label for="name">Enter your name:</label>
<input id="name" name="name">

This form can give you all the information you need, and even a screen reader can figure it out :)

This is mentioned here in Creating Accessible Forms, as well as many other sources.

Upvotes: 2

Related Questions