我的搜索表單目前的HTML看起來像這樣:製作一個搜索表單殘障:標籤與ARIA標籤VS詠歎調,labelledby
<form action=「/search/」 method="post">
<input onclick="this.value='';" type="text" name="searchquery" id="searchbox" value="Search this site」 class="swap_value" />
<input type="image" src=「/images/searchbutton.gif" id="searchbutton" alt="" />
</form>
我想使搜索形式訪問。據我瞭解,從W3.org無障礙:https://www.w3.org/WAI/tutorials/forms/labels/和a11ymatters.com:http://www.a11ymatters.com/pattern/accessible-search/,我需要補充,不會在視覺上顯示一個標籤,並給予說明,以搜索按鈕,如下所示:
隨着添加CSS:
.search-label {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
的W3.org文章說,你可以使用標籤,ARIA標籤,或唱段,labelledby識別表單控件,但它並沒有說這是最好的做法。有誰知道哪一個是首選/最佳實踐? alt標籤是否足以識別我的搜索按鈕,還是需要標籤?
非常感謝!
只是一個快速評論,標籤應與您的示例中的輸入文本框「搜索框」相關聯,而不是搜索按鈕。 –