WordCamp US: ARIA. Roles, States and Properties

23
ARIA Roles, States, and Properties #wparia @joedolson

Transcript of WordCamp US: ARIA. Roles, States and Properties

Page 1: WordCamp US: ARIA. Roles, States and Properties

ARIARoles, States, and Properties

#wparia @joedolson

Page 2: WordCamp US: ARIA. Roles, States and Properties

AccessibleRichInternetApplications

Page 3: WordCamp US: ARIA. Roles, States and Properties

Roles, States and Properties

●ARIA uses special HTML attributes

●Roles define what function an element serves

●States defines how you interact with an element

●Properties give an element characteristics and relationships.

●Use ARIA with CSS and JS

Page 4: WordCamp US: ARIA. Roles, States and Properties

The Role:What am I?

Page 5: WordCamp US: ARIA. Roles, States and Properties

Implicit vs. Explicit

Page 6: WordCamp US: ARIA. Roles, States and Properties

<h1>

What am I?</h1>

Page 7: WordCamp US: ARIA. Roles, States and Properties

<div role="tabpanel">

What am I?</div>

Page 8: WordCamp US: ARIA. Roles, States and Properties

Supplement, don’t replace.

● Redundant: <h1 role="heading" aria-level="1">

● Replacement: <p role="heading" aria-level="1">

● Modifier: <h1 role="heading" aria-level="2">

Page 9: WordCamp US: ARIA. Roles, States and Properties

Use 'em if you got 'em.There’s an element for that...

Page 10: WordCamp US: ARIA. Roles, States and Properties

<div role="checkbox">

What am I?</div>

Page 11: WordCamp US: ARIA. Roles, States and Properties

The State:What am I doing now?

Page 12: WordCamp US: ARIA. Roles, States and Properties

<button id="menu-toggle">Toggle Menu</button>

Page 13: WordCamp US: ARIA. Roles, States and Properties

<button id="menu-toggle"aria-expanded="true"

>Toggle Menu</button>

Page 14: WordCamp US: ARIA. Roles, States and Properties

Wanna style that?

JS:

$( this ).attr( 'aria-expanded', 'true' ).addClass( 'open' );

CSS:

.open {/* style me, baby */}

JS:

$( this ).attr( 'aria-expanded', 'true' );

CSS:

#menu-toggle[aria-expanded='true'] {/* style me, baby */

}

Page 15: WordCamp US: ARIA. Roles, States and Properties

The Properties:Who am I related to?What do you need to know about me?

Page 16: WordCamp US: ARIA. Roles, States and Properties

<button id="menu-toggle"aria-expanded="true"

>Toggle Menu</button>

Page 17: WordCamp US: ARIA. Roles, States and Properties

<button id="menu-toggle"aria-expanded="true"aria-controls="menu-main-menu"

>Menu</button>

Page 18: WordCamp US: ARIA. Roles, States and Properties

<button id="menu-toggle"aria-expanded="true"aria-controls="menu-main-menu"aria-label="Close Main Navigation Menu"

>Menu</button>

Page 19: WordCamp US: ARIA. Roles, States and Properties

What do you need to know about me?

●aria-label

●aria-live

●aria-atomic

●aria-required

Page 20: WordCamp US: ARIA. Roles, States and Properties

Who am I related to?

●aria-controls

●aria-describedby

●aria-labelledby

●aria-owns

Page 21: WordCamp US: ARIA. Roles, States and Properties

ARIA: In Summary

●If you can use a native element, use it.

●For non-native HTML controls, add your own keyboard handlers.

●Make the current state of any interactive element explicit.

●Make relationships between control and controlled explicit.

●Provide a clear accessible name for all controls.

Page 22: WordCamp US: ARIA. Roles, States and Properties

Resources

5 Rules of ARIA use: http://www.w3.org/TR/aria-in-html/#first-rule-of-aria-use

W3C Overview: http://www.w3.org/WAI/intro/aria

Implicit Roles: http://html5doctor.com/on-html-belts-and-aria-braces/

What is WAI ARIA? https://www.marcozehe.de/2014/03/27/what-is-wai-aria-what-does-it-do-for-me-and-what-not/

Page 23: WordCamp US: ARIA. Roles, States and Properties

Questions? I'm here all day.

Joe Dolsonhttps://www.joedolson.com

Twitter: @joedolson