Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 846
user2286693 Avatar asked Oct 31 '22 07:10

user2286693


1 Answers

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.

like image 84
unor Avatar answered Nov 12 '22 20:11

unor