HTML5 有效表单输入/字段
我对于什么被认为是 HTML5 输入字段的有效标记有点困惑。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Site Name</title>
</head>
<body>
<form name="contact" method="post" action="/">
<p><input type="input" name="first_name" maxlength="255" /></p>
</form>
</body>
</html>
当我通过 w3.org 的验证器运行此命令时,我收到错误 Bad value input for attribute type on element input.
,其中 />
以红色突出显示。我查看了它创建的 HTML-Tidy 版本,它告诉我要这样写:
<p><input type="input" name="first_name" maxlength="255"></p>
但是当我验证时,我会得到相同的错误,但只有 >
以红色突出显示。然后查看 HTML-Tidy,看看它已将其更正为什么,结果就像没问题一样,但错误仍然存在。这是否被视为有效的 HTML5 标记?或者有具体的方法可以做到这一点吗?
I'm a little confused as to what is considered valid markup for HTML5 input fields.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Site Name</title>
</head>
<body>
<form name="contact" method="post" action="/">
<p><input type="input" name="first_name" maxlength="255" /></p>
</form>
</body>
</html>
When I run this through the validator at w3.org I get the error Bad value input for attribute type on element input.
with the />
highlighted in red. I look at the HTML-Tidy version it creates and it tells me to write it like this instead:
<p><input type="input" name="first_name" maxlength="255"></p>
But then when I validate that I then get the same error but with just the >
highlighted in red. Then looking at the HTML-Tidy to see what it has corrected it to and it leaves is the same as if it's okay, but the error is still there. Is this considered valid HTML5 markup? Or is there a specific way of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
type="input"
是input
元素的属性type
的无效值。此有关输入元素的指南显示了允许的
type
属性。或者,如果您需要其中一种,请检查HTML5其他输入类型那些。对于常规文本字段,您需要将 type 属性设置为
type="text"
。type="input"
is an invalid value of the attributetype
of theinput
element.This guide on the input element shows the allowed
type
attributes. Or check the HTML5 additional input types if you require one of those.For a regular textfield you need to set the type attribute to
type="text"
.输入类型“input”不正确,您可能打算使用
type="text"
。Input type "input" is not correct, you probably intented to use
type="text"
.