Aria-label
Normally, the input component of the form form has a corresponding label. When the input component gets the focus, the screen reader reads the text from the corresponding label.
Such as:
But if we don't set the label for the input box, when it gets the focus, the screen reader reads out the value of the Aria-label property, and Aria-label does not visually render the effect.
Such as:
<body>
<form role = "form" >
<div class= "Form-group col-lg-3 form-horizontal" >
<div class= "Col-lg-7" >
<input type = "text" id = "Idcard" class= "form-control" Aria-label = "identity card number" >
</div >
</div>
</form>
Aria-labelledby Property
When the desired label text already exists in another element, you can use Aria-labelledby and value it as the ID of all the read elements. As follows:
When the UL gets to the focus, the screen reader reads: "Choose your Position"
<body>
<div class= "dropdown" >
<button type= "button" class= "btn dropdown-toggle" id= " DropdownMenu1 "
data-toggle=" dropdown ">
Select your position
<span class=" caret "></span>
</ button>
<ul class= "Dropdown-menu" role= "menu" aria-labelledby= "dropdownMenu1" >
<li role= " Presentation ">
<a role=" MenuItem "tabindex="-1 "href=" # "> Test Engineer </a>
</li>
< Li role= "presentation" >
<a role= "MenuItem" tabindex= "-1" href= "#" > Development Engineer </a>
</li>
<li role= "Presentation" >
<a role= "MenuItem" tabindex= "-1" href= "#" > Sales Engineer </a>
</li>
</ul>
</div>
PS: If an element has Aria-labelledby and Aria-label at the same time, the read-screen software will first read out the Aria-labelledby content
The above content is a small series to introduce the bootstrap Aria-label and Aria-labelledby application related content, hope this article to share can bring help to everybody, at the same time thanks everybody has been to cloud Habitat community website support.