Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的 Web 应用程序中,我有文本框,但由于某些特定目的,我不想为其分配标签。但是为了提供可访问性,它需要标签与每个文本框相关联。在这种情况下,如何在不向文本框提供任何标签的情况下处理可访问性?提前致谢!
我认为你可以做到<input aria-label="my label here" />。这样您就不必拥有标签属性/额外的 DOM 节点,但屏幕阅读器仍应读出 aria-label 文本。或者,您可以使用<label>标签并使用 CSS 将其隐藏。
<input aria-label="my label here" />
<label>