What are these attributes: `aria-labelledby` and `aria-hidden`

前端 未结 5 1535
别跟我提以往
别跟我提以往 2020-12-07 10:09

Using Bootstrap modal, I\'ve seen these aria attributes a lot, but I never knew how to make use of them.

Does anyone know what cases to use these attri

5条回答
  •  無奈伤痛
    2020-12-07 10:56

    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-hidden:

    aria-hidden attribute is used to hide content for visually impaired users who navigate through application using screen readers (JAWS, NVDA,...).

    aria-hidden attribute is used with values true, false.

    How To Use:

    
    

    using aria-hidden = "true" on the hides content to screen reader users with no visual change in the application.

    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 
    
    
    

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

    Approach 2:

     Billing Address 
    
     First Name 
    
    
    

提交回复
热议问题