What is aria-label and how should I use it?

前端 未结 6 2032
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 16:52

A few hours ago I read about the aria-label attribute, which:

Defines a string value that labels the current element.

But in my

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 17:37

    Prerequisite:

    Aria is used to improve the user experience of visually impaired users. Visually impaired users navigate though application using screen reader software like JAWS, NVDA,.. While navigating through the application, screen reader software announces content to users. Aria can be used to add content in the code which helps screen reader users understand role, state, label and purpose of the control

    Aria does not change anything visually. (Aria is scared of designers too).

    aria-label

    aria-label attribute is used to communicate the label to screen reader users. Usually search input field does not have visual label (thanks to designers). aria-label can be used to communicate the label of control to screen reader users

    How To Use:

    
    

    There is no visual change in application. But screen readers can understand the purpose of control

    aria-labelledby

    Both aria-label and aria-labelledby is used to communicate the label. But aria-labelledby can be used to reference any label already present in the page whereas aria-label is used to communicate the label which i not displayed visually

    Approach 1:

    Search
    
    
    

    Approach 2:

    aria-labelledby can also be used to combine two labels for screen reader users

    Billing Address
    
    First Name
    
    
    

提交回复
热议问题