Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 验证器说在标记搜索栏时按钮必须有一个id_Html_Forms_Validation_Label_Html Validation - Fatal编程技术网

Html 验证器说在标记搜索栏时按钮必须有一个id

Html 验证器说在标记搜索栏时按钮必须有一个id,html,forms,validation,label,html-validation,Html,Forms,Validation,Label,Html Validation,这是我的代码,当我用html验证器验证它时,它说: “具有for属性的标签元素的任何按钮子体都必须 具有与属性的ID值匹配的ID值。“ 我的问题是,这个按钮是放大镜的图标,你可以按它而不是按enter来搜索。现在我想让它在搜索栏上贴上那个玻璃标签(还有“搜索”),这样有screenreader的人可以更容易地使用它。但是验证器说这是一个错误 有什么建议吗 <form action="/searchresults" method="POST" id="searchbar"> <

这是我的代码,当我用html验证器验证它时,它说:

“具有for属性的标签元素的任何按钮子体都必须 具有与属性的ID值匹配的ID值。“


我的问题是,这个按钮是放大镜的图标,你可以按它而不是按enter来搜索。现在我想让它在搜索栏上贴上那个玻璃标签(还有“搜索”),这样有screenreader的人可以更容易地使用它。但是验证器说这是一个错误

有什么建议吗

<form action="/searchresults" method="POST" id="searchbar">
  <input type="search" id="search" name="search" autocomplete="off">
  <label for="search">
    <button type="submit" class="searchicon">
      Search
    </button>
  </label>
</form>

搜寻

“现在我想让它在搜索栏上贴上那个玻璃标签(和“搜索”),这样屏幕阅读器的用户就可以更轻松地使用它。”——你是什么意思?您拥有的当前标签嵌套的是按钮,而不是输入元素。是的,按钮嵌套,但我使用“for”属性分配给id为的输入元素。澄清一下:我希望按钮标签位于搜索栏上。