仅包含一个按钮的段落是否无法访问?

Is a paragraph inaccessible when it contains only a button?

Tenon.io 将此代码标记为无效,因为它是 "paragraph without text in it".

<p class="dataform-submit">
  <input type="submit" value="Submit request" />
</p>

这段代码真的是"inaccessible"吗?应该使用哪个语义块标记来包含提交按钮(通常是表单的一部分)?

不,这并非不可访问。

我不认为 p is the most appropriate¹ element here, because this button doesn’t really represent the "typical" paragraph,但在这种情况下,标记选择根本不应该影响可访问性。这是语义标记的问题,而不是可访问性。

每个有能力的用户代理都应该能够处理包含文本和按钮的 p(在许多情况下这是一个有意义的组合)。从中删除文本不会突然从根本上改变某些东西,因此没有理由假设存在无法再处理它的用户代理。

¹ 我根本不使用父元素,或者如果出于样式目的需要父元素,则使用无意义的 div.

您的段落不为空,Tenon 上的解释不适用于此处:

A paragraph was found without text in it. While this tends to have a low severity, it does create an unnecessary nuisance for users of screen readers who are likely to hear the announcement of the empty paragraph as they navigate through content. If this empty paragraph exists to behave as margin, use CSS for this purpose instead.

您的 input 有一个文本替换字符串,算法应该考虑它。

这是一个错误。而且这个测试完全是胡说八道,因为如果这里使用 div,屏幕阅读器不会有任何区别。