html - W3C 验证器错误 : Attribute placeholder is only allowed when the input type is

标签 html placeholder w3c-validation html-input

给定 HTML 文档

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

W3C validator (v1.3) 给出以下错误信息:

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

为什么?

最佳答案

这似乎是验证器中的错误。

两个验证器,http://validator.w3.org/http://validator.w3.org/nu/ , 报告 placeholder 属性“仅当输入类型为 e-mail […] 时才允许”。
但是,HTML5 输入类型称为 email ,而不是 e-mail(如果使用 type="e-mail",两个验证器都能正确识别)。

不看代码,我猜当使用 placeholder 时,他们会检查 e-mail 而不是 email。它与所有其他允许的输入类型一起按预期工作。

关于html - W3C 验证器错误 : Attribute placeholder is only allowed when the input type is,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29333088/

相关文章:

python - 嵌套 python 字典中的字符串替换/格式化占位符值

html - 显示输入类型日期的占位符文本

javascript - 是否有任何单一工具可以在给定目录中的文件上运行 JSLint、W3C 验证器(CSS3 和 HTML5)?

jquery - 带有 Bootstrap 的多个下拉菜单不起作用?

php - 也可以在 php 和 html 和 javascript 悬停效果中导航

html - Rails 静态页脚布局

python - python mysql 中表名的占位符

javascript - jquery 调整大小功能不起作用

html - 如果您的代码对 Transitional 文档类型有效,我们是否应该使用严格的文档类型?

jquery - jQuery 的 W3C 标记验证错误