2016-07-01 61 views
1

作爲一個網絡無障礙工作的一部分,我們的網站被拾起的一些缺失表單標籤無障礙網頁失敗的「失蹤表單標籤」

文本區域是我們不希望有對可見光的標籤元素(該網站是ASP.NET MVC /剃鬚刀使用jQuery)

@Html.TextAreaFor(x => x.UserInput.FeedbackContent) 

是正確的做法是這種情況下創建一個相應的LabelFor藏起來呢?

@Html.LabelFor(x => x.UserInput.FeedbackContent, new {@class = 'hidden'}) 

或者有沒有在TextArea內創建隱藏標籤的方法?

非常感謝

回答

0

是正確的做法是這樣的情況下,纔會產生相應LabelFor藏起來呢?

如果你不通過display: nonevisibility: hidden隱藏它,因爲那些會make screenreaders ignore it as well

There are您可以用它來隱藏它的CSS技巧,但是可以考慮在文本區域本身使用aria-label屬性。在HTML中,這將是:

<textarea ... aria-label="Label for the text area" ...> 

我不使用Asp.Net MVC的,但我相信你是這樣做的:

@Html.TextAreaFor(x => x.UserInput.FeedbackContent, new Dictionary<string, object>(){{"aria-label", "Label for the text area"}}); 
+0

非常感謝 - 所以不是太熟悉ASP MVC/Razor,我將如何通過@ Html.TextAreaFor設置該屬性?它是新的{@attribute =「aria_label ='文本區域的標籤'」} – Mike

+0

@Mike:嘿,我只是研究並將其添加到答案(見上文,你可能需要刷新)。我基於[這個答案](http://stackoverflow.com/a/2539117/157247)關於一個不相關的屬性。 –