html - 没有属性 "placeholder"也没有属性 "autocomplete"

标签 html doctype w3c w3c-validation

使用 http://validator.w3.org/ 验证时,我的页面上出现以下错误 没有属性“占位符” 没有属性“自动完成”

详细说:

Line 59, Column 81: there is no attribute "placeholder" …rd" type="text" style="width:500px;" placeholder=" What" autocomplete="off" /> ✉ You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the element to incorporate flash media in a Web page, see the FAQ item on valid flash.

html 标签在这里:<input name="keyword" id="keyword" type="text" style="width:500px;" placeholder=" What" autocomplete="off" />

最佳答案

如果您使用的是 html5,那么您应该使用普通的文档类型。

<!DOCTYPE HTML>
<html>
<head>
<TITLE>My first HTML document</TITLE>
</head>
<body>
  <input name="keyword" id="keyword" type="text" style="width:500px;" placeholder=" What" autocomplete="off" />
</body>
</html>

如果您使用的是 html4 或其他任何东西,那么您可以使用以下其中之一

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

更多信息..

http://www.w3.org/TR/html-markup/syntax.html#normal-doctype

关于html - 没有属性 "placeholder"也没有属性 "autocomplete",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22652514/

相关文章:

html - 将操纵输出与 knitr 集成

javascript - 网络共享 api 级别 2 PDF 支持

html - 如何将 border-bottom 应用于最后一个非空 <tr>?

javascript - ng-click 在第一次单击后不起作用(嵌入指令)

html - 为什么 doctype 会改变 'display:table-cell' ' 的行为

html - 为什么这些子菜单没有出现在 IE 中?

java - 如果输入文件中未指定 DTD,我如何强制 SAX 解析器使用 DTD?

javascript - Google +1 按钮不符合 W3C 标准

java - 无法将 xml 字符串转换为 w3c 文档

html - Safari 自动 "display: none !important"不会加载图像