Html Chrome audit:表单元素没有关联的标签

Html Chrome audit:表单元素没有关联的标签,html,google-chrome-devtools,Html,Google Chrome Devtools,在Chrome中审核我的产品页面后,我收到此错误: 表单元素没有关联的标签 失败因素 输入#数量_5ce535030e171.输入文本.数量文本 input#woocommerce-product-search-field-0.搜索字段 标签清楚地指示输入带有for属性的标签 元素#1: <div class="quantity"> <label class="screen-reader-text" for="quantity_5ce535030e171">My prod

在Chrome中审核我的产品页面后,我收到此错误:

表单元素没有关联的标签

失败因素

输入#数量_5ce535030e171.输入文本.数量文本

input#woocommerce-product-search-field-0.搜索字段

标签清楚地指示
输入
带有
for
属性的标签

元素#1:

<div class="quantity">
<label class="screen-reader-text" for="quantity_5ce535030e171">My product name</label>
<input type="number" id="quantity_5ce535030e171" class="input-text qty text" step="1" min="1" max="" name="quantity" value="1" title="Qty" size="4" inputmode="numeric">
</div>
<form role="search" method="get" class="woocommerce-product-search" action="https://example.com/example-product/">
<label class="screen-reader-text" for="woocommerce-product-search-field-0">Search for:</label>
<input type="search" id="woocommerce-product-search-field-0" class="search-field" placeholder="Search products…" value="" name="s">
<button type="submit" value="Search">Search</button>
<input type="hidden" name="post_type" value="product">
</form>

我的产品名称
元素#2:

<div class="quantity">
<label class="screen-reader-text" for="quantity_5ce535030e171">My product name</label>
<input type="number" id="quantity_5ce535030e171" class="input-text qty text" step="1" min="1" max="" name="quantity" value="1" title="Qty" size="4" inputmode="numeric">
</div>
<form role="search" method="get" class="woocommerce-product-search" action="https://example.com/example-product/">
<label class="screen-reader-text" for="woocommerce-product-search-field-0">Search for:</label>
<input type="search" id="woocommerce-product-search-field-0" class="search-field" placeholder="Search products…" value="" name="s">
<button type="submit" value="Search">Search</button>
<input type="hidden" name="post_type" value="product">
</form>

搜索:
搜寻

html中是否有任何错误或Chrome出现错误?

看起来这是根据在axe core 3.2.0中修复的错误,但自Chrome版本75.0.3770.142起,该修复仍未纳入Lighthouse

Lighthouse将Axe用于其审计的可访问性部分,但您可以将Axe作为独立程序运行。我在一个网站上运行了独立的扩展(版本3.8.0和axe core 3.2.2),该网站使用了视觉隐藏的表单标签,并通过了;然而灯塔仍然因为你提到的错误而失败。据我所知,根据审计结果中的“了解更多”链接,Lighthouse正在使用axe core的3.1版


只要
。屏幕阅读器文本的样式不使用
显示:无
可见性:隐藏,或者将宽度或高度归零,它应该通过独立的Axe扩展审核。

看起来这是Axe core 3.2.0中根据修复的错误,但从Chrome版本75.0.3770.142起,该修复仍然没有纳入Lighthouse

Lighthouse将Axe用于其审计的可访问性部分,但您可以将Axe作为独立程序运行。我在一个网站上运行了独立的扩展(版本3.8.0和axe core 3.2.2),该网站使用了视觉隐藏的表单标签,并通过了;然而灯塔仍然因为你提到的错误而失败。据我所知,根据审计结果中的“了解更多”链接,Lighthouse正在使用axe core的3.1版


只要
。屏幕阅读器文本的样式不使用
显示:无
可见性:隐藏,或者将宽度或高度归零,它应该通过独立Axe扩展审计。

您的代码在我看来还可以。您可以尝试将
嵌套为
的子项。我已将关联的
输入
标记嵌套为
标签
的子项,不幸的是,我仍然收到相同的错误。一切都在最新的Chrome上。也许是这个问题?这似乎确实相关。如果您安装了Lighthouse扩展,您可能可以检查问题是否已修复。我相信这个扩展正在运行Lighthouse v5。我已经测试了Lighthouse扩展,事实上这个错误已经不再存在了。希望这能很快送到浏览器上。我觉得你的代码还可以。您可以尝试将
嵌套为
的子项。我已将关联的
输入
标记嵌套为
标签
的子项,不幸的是,我仍然收到相同的错误。一切都在最新的Chrome上。也许是这个问题?这似乎确实相关。如果您安装了Lighthouse扩展,您可能可以检查问题是否已修复。我相信这个扩展正在运行Lighthouse v5。我已经测试了Lighthouse扩展,事实上这个错误已经不再存在了。希望这能很快送到浏览器上。