user2286693
user2286693

Reputation: 3167

W3C validator error: Attribute placeholder is only allowed when the input type is

Given the HTML document

<!DOCTYPE html> 
<html>
  <head>
    <title>Title</title>
  </head> 
  <body>
    <form> 
      <input type="email" placeholder="E-Mail"/>
    </form>  
  </body>
</html>

the W3C validator (v1.3) gives the following error message:

Line 8, Column 48: Attribute placeholder is only allowed when the input type is e-mail, number, password, search, tel, text, or url.

Why?

Upvotes: 5

Views: 3666

Answers (1)

unor
unor

Reputation: 96707

This seems to be a bug in the validator.

Both validators, http://validator.w3.org/ and http://validator.w3.org/nu/, report that the placeholder attribute is "only allowed when the input type is e-mail […]".
However, the HTML5 input type is called email, not e-mail (which both validators correctly recognize if type="e-mail" is used instead).

Without looking at the code, I guess that when placeholder is used, they check for e-mail instead of email. It works as expected with all other allowed input types.

Upvotes: 2

Related Questions