It’s the markup that matters

A presentation at Modern Frontends Live! in November 2022 in London, UK by Hidde de Vries

Slide 1

Slide 1

Slide 2

Slide 2

@hdv html

Slide 3

Slide 3

@hdv html enables

Slide 4

Slide 4

@hdv Multi device web html enables

Slide 5

Slide 5

@hdv fi This NeXT machine was used to develop and run the rst WWW server, multimedia browser and web editor

Slide 6

Slide 6

@hdv Multi device web html enables

Slide 7

Slide 7

@hdv Multi device web Default stylesheets html enables

Slide 8

Slide 8

@hdv Multi device web Default stylesheets ‘Browse by heading’ html enables

Slide 9

Slide 9

@hdv Multi device web Default stylesheets ‘Browse by heading’ html enables Default behaviour

Slide 10

Slide 10

@hdv Default stylesheets Multi device web ‘Browse by heading’ html enables Reader mode Default behaviour

Slide 11

Slide 11

@hdv

Slide 12

Slide 12

@hdv Default stylesheets ‘Browse by heading’ Multi device web html enables Reader mode Default behaviour

Slide 13

Slide 13

@hdv@front-end.social It’s the markup that matters Hidde de Vries, Modern Frontends Live, London, 18 November 2022

Slide 14

Slide 14

@hdv Hi, I’m Hidde developer relations + accessibility specialist sanity.io hidde.blog @hdv

Slide 15

Slide 15

sanity.io platform for structured content / deeply customisable CMS / content as data @hdv

Slide 16

Slide 16

@hdv Let’s talk accessbility

Slide 17

Slide 17

@hdv Web accessibility to ensure people with disabilities can use your site/app

Slide 18

Slide 18

@hdv Web accessibility to ensure people with disabilities can buy your product

Slide 19

Slide 19

@hdv Web accessibility to ensure people with disabilities can use your service

Slide 20

Slide 20

@hdv 1-2% 4% blind/visually impaired colour blind ` OOGVERENIGING (1 IN 12 MEN, 1 IN 250 WOMEN) neurological conditions This concerns a lot of people 9% motor impairments 15% deaf/heard of hearing low numerate / low literate HOORWIJZER ALGEMENE REKENKAMER

Slide 21

Slide 21

@hdv A lot of people Use high contrast modes

Slide 22

Slide 22

@hdv A lot of people Zoom in on web pages

Slide 23

Slide 23

@hdv A lot of people Prefer reduced motion

Slide 24

Slide 24

@hdv A lot of people Do not use a mouse

Slide 25

Slide 25

@hdv A lot of people - zoom in web pages use high contrast modes use assistive technologies need audio/video transcribed do not use a mouse use voice recognition prefer reduced motion W3C/WAI, How People with Disabilities Use the Web https://www.w3.org/WAI/people-use-web/tools-techniques

Slide 26

Slide 26

@hdv A lot of people - zoom in web pages use high contrast modes use assistive technologies need audio/video transcribed do not use a mouse use voice recognition prefer reduced motion W3C/WAI, How People with Disabilities Use the Web https://www.w3.org/WAI/people-use-web/tools-techniques

Slide 27

Slide 27

@hdv A lot of people - zoom in web pages use high contrast modes use assistive technologies need audio/video transcribed do not use a mouse use voice recognition prefer reduced motion Image credits: Apple, Wikipedia

Slide 28

Slide 28

@hdv What our markup does

Slide 29

Slide 29

Photo: brianna.lehman on Flickr

Slide 30

Slide 30

Photo: Stephen Fulljames on Flickr

Slide 31

Slide 31

@hdv f Accessible code provides semantics: it points machines at what stu f is

Slide 32

Slide 32

document object model

Slide 33

Slide 33

Example of an Accessibility Tree・ https://github.com/WICG/aom/blob/gh-pages/images/a11y-node.png

Slide 34

Slide 34

accessibility tree Role What kind of thing is it? Name/Description How should we refer to it? State/properties What else should we know?

Slide 35

Slide 35

Slide 36

Slide 36

role: link name: “World”

Slide 37

Slide 37

role: link name: “US politics”

Slide 38

Slide 38

role: link name: “Business”

Slide 39

Slide 39

role: button name: “Edition”

Slide 40

Slide 40

Accessibility tree Platform APIs AT Your markup Microsoft Active Accessibility Microsoft User Interface Automation MSAA DOM tree Mac OS X Accessibility Protocol text-to-speech fi Linux/Unix Accessibility Toolkit IAccessible2 screen magni ers alternate pointing devices

Slide 41

Slide 41

Firefox < < Chromium

Slide 42

Slide 42

@hdv it’s the markup that matters, in practice

Slide 43

Slide 43

@hdv (The following examples work with all of your favourite tools)

Slide 44

Slide 44

@hdv Where am I?

Slide 45

Slide 45

<html lang=”en”> <head> <title>It’s the markup that matters Presentations - My site</title> </head> <body> … </body> </html>

Slide 46

Slide 46

@hdv [The <title>] is still the rst guarantee or rst con rmation that you’ve ended up on the page that you intended to reach. — Léonie Watson, accessibility expert and screenreader user fi fi fi Smashing TV with Léonie Watson・ https://www.youtube.com/watch?v=iUCYPM6up9M.

Slide 47

Slide 47

@hdv What is on this page? Headings

Slide 48

Slide 48

Whenever you use <h1>, <h2>, <h3>, … people can: - navigate by heading - see headings in reader mode

Slide 49

Slide 49

@hdv Every detail counts fi Speci cations

Slide 50

Slide 50

@hdv Which areas are on this page?

Slide 51

Slide 51

@hdv Landmarks let you specify which sections a page has, so that people can navigate to them

Slide 52

Slide 52

@hdv HTML5 ARIA roles

<header> <footer> <nav> <aside> <main> role=”banner” role=”contentinfo” role=”navigation” role=”complementary” role=”main”

Slide 53

Slide 53

@hdv The more landmarks one has in a document, especially landmarks of the same type, the less meaningful they become — Scott O’Hara, accessibility specialist Scott O’Hara: Accessible landmarks・ https://www.scottohara.me/blog/2018/03/03/landmarks.html

Slide 54

Slide 54

@hdv I would still love this as a browser feature fi Hidde de Vries: Could browsers x more accessibility problems automatically?・ https://talks.hiddedevries.nl/Lh9wu2

Slide 55

Slide 55

@hdv Form controls

Slide 56

Slide 56

@hdv “46.1% of form inputs were not properly labeled.” — WebAIM WebAIM: the WebAIM Million (2022 data)・ https://webaim.org/projects/million/

Slide 57

Slide 57

@hdv fi Label input elds, radio buttons, checkboxes, selects, textareas, etc… so that they have a name

Slide 58

Slide 58

City

<div class=”form-item”> City <input type=”text” /> </div> Role: ‘textbox’ / ‘entry’ Name: null / ”

Slide 59

Slide 59

Accessible Name and Description Computation 1.1 ・ https://www.w3.org/TR/accname-1.1/

Slide 60

Slide 60

City

<div class=”form-item”> <label for=”city”>City</label> <input id=“city” type=”text” /> </div> Role: ‘textbox’ / ‘entry’ Name: ‘City’

Slide 61

Slide 61

@hdv Table semantics

Slide 62

Slide 62

@hdv Tables make tabular data easier to navigate

Slide 63

Slide 63

<table> <caption>Net results 2018</caption> <thead> <tr> <th scope=”col”>Assets</th> Use table semantics <th scope=”col”>Capital</th> … </tr> </thead> <tbody> … </tbody> </table>

Slide 64

Slide 64

Slide 65

Slide 65

@hdv Buttons

Slide 66

Slide 66

fi Whenever you use <button> people can: - nd it in TAB order - press it with just a keyboard - submit the form, even if JS fails

Slide 67

Slide 67

The “Add Reaction” button

Slide 68

Slide 68

// use the button element <button type=”button”> <svg class=”icon”> <use xlink:href=”#emoji”></use> </svg> </button> Role: ‘button’ Name: ”

Slide 69

Slide 69

<button type=”button” aria-label=”Add reaction”> <svg class=”icon”> <use xlink:href=”#emoji”></use> </svg> </button> Role: ‘button’ Name: ‘Add reaction’

Slide 70

Slide 70

<button type=”button”> <svg class=”icon”> <use xlink:href=”#emoji”></use> </svg> // add accessible name <span class=”visually-hidden”> Add reaction </span> </button> Role: ‘button’ Name: ‘Add reaction’

Slide 71

Slide 71

@hdv The HTML spec is the place to nd out how to use HTML developers.whatwg.org fi HTML: The Living Standard・ https://developers.whatwg.org

Slide 72

Slide 72

@hdv HTMHell collects examples of how not to use HTML HTMHell・ https://htmhell.dev

Slide 73

Slide 73

@hdv accessibility object model

Slide 74

Slide 74

@hdv “develop additions to the web platform to allow developers to provide information to assistive technology APIs, and to understand what information browsers provide to those APIs” — The AOM explainer document The Accessibility Object Model (AOM) ・ https://github.com/WICG/aom

Slide 75

Slide 75

const el = document.querySelector(“el”); el.role = “button”; el.ariaDisabled = false; Setting a11y info with idl properties fi (user-visible, user -modi able)

Slide 76

Slide 76

const el = document.querySelector(“el”); Setting a11y info with idl properties internally fi (not user-visible, not user-modi able; avoids sprouting) el._internals.role = “button”; el._internals.ariaDisabled = false;

Slide 77

Slide 77

Relationships without IDREFs

Slide 78

Slide 78

IDREFs don’t work across Shadow boundaries Cross-root ARIA Delegation API explainer・ github.com/leobalter/cross-root-aria-delegation/blob/main/cross-root-aria-delegation.md

Slide 79

Slide 79

“an API to forward ARIA attributes and properties set on a Web Component to elements inside of its shadowroot” — Cross-root ARIA Delegation API explainer Cross-root ARIA Delegation API explainer・ github.com/leobalter/cross-root-aria-delegation/blob/main/cross-root-aria-delegation.md

Slide 80

Slide 80

Events from Assistive Technologies

Slide 81

Slide 81

Events from Assistive Technologies synthesised Dom events

Slide 82

Slide 82

reading accessibility tree from javascript (w/ outdated syntax)

Slide 83

Slide 83

@hdv future elements

Slide 84

Slide 84

@hdv the power of the web platform HTML comes with accessibility built in

Slide 85

Slide 85

@hdv But there isn’t HTML for everything!

Slide 86

Slide 86

@hdv

Slide 87

Slide 87

@hdv “We hope to make it unnecessary to reinvent built-in UI controls” — OpenUI homepage

Slide 88

Slide 88

@hdv Standardised controls can be a huge opportunity for accessibility

Slide 89

Slide 89

@hdv

Slide 90

Slide 90

@hdv Standardised controls can be a huge opportunity for accessibility (if accessibility considerations are met)

Slide 91

Slide 91

EX PE R IM EN TA L @hdv <selectmenu>

Slide 92

Slide 92

@hdv developers on <select> Hard to build “search in list” UI Can’t customise popup window — 27.43% of respondents — 11.36% of respondents (desktop) Can’t style <option> Need to insert arbitrary HTML Can’t style default state — 17.85% of respondents — 7.82% of respondents — 14.01% of respondents Greg Whitworth, Can we please style the <select> control?!・ https://www.gwhitworth.com/posts/2019/can-we-please-style-select/

Slide 93

Slide 93

// regular select <select> <option>Tabs</option> <option>Spaces</option> Firefox

<option>A mix of both</option> </select> Edge

Slide 94

Slide 94

<selectmenu> <option>Tabs</option> <option>Spaces</option> <option>A mix of both</option> </select> Example from FAST UI・ https://explore.fast.design/components/fast-select L TA EN IM R PE EX // introducing… <selectmenu>

Slide 95

Slide 95

Example from FAST UI・ https://explore.fast.design/components/fast-select L TA EN IM R PE EX selectmenu::part(button) { background-color: #f00; border-radius: 5px; }

Slide 96

Slide 96

selectmenu::part(listbox) { padding: 10px; margin-top: 5px; } Example from FAST UI・ https://explore.fast.design/components/fast-select L TA EN IM R PE EX selectmenu::part(button) { background-color: #f00; border-radius: 5px; }

Slide 97

Slide 97

selectmenu::part(listbox) { padding: 10px; margin-top: 5px; } selectmenu::part(selected-value) { padding: 10px; margin-top: 5px; } Example from FAST UI・ https://explore.fast.design/components/fast-select L TA EN IM R PE EX selectmenu::part(button) { background-color: #f00; border-radius: 5px; }

Slide 98

Slide 98

L TA EN IM R PE EX <selectmenu> browser support Experimental, behind lags, known accessibility issues about: lags, “Experimental Web Features” f f @hdv

Slide 99

Slide 99

EX PE R IM EN TA L @hdv popover attribute (formerly known as “popup”)

Slide 100

Slide 100

@hdv popover would be an attribute for HTML to make popuplike behaviors easier to build

Slide 101

Slide 101

@hdv popover examples action menus teaching UI form element suggestions content pickers <select>’s listbox Chrome Platform Status: The Popup API・ https://chromestatus.com/feature/5463833265045504

Slide 102

Slide 102

@hdv common popover behaviours on top of other page content only open when it needs to be usually one at the time Popup API (Explainer)・ https://open-ui.org/components/popup.research.explainer

Slide 103

Slide 103

<div> <h3>Replace image</h3> <button>Upload</button> <button>Browse</button> … </div> L TA EN IM R PE EX // create a popover

Slide 104

Slide 104

<div popover> <h3>Replace image</h3> <button>Upload</button> <button>Browse</button> … </div> L TA EN IM R PE EX // give this popup behavior

Slide 105

Slide 105

<div popover id=”options”> <h3>Replace image</h3> <button>Upload</button> <button>Browse</button> … </div> L TA EN IM R PE EX // add a unique ID

Slide 106

Slide 106

<button togglepopover=”options”> Image options </button> // give this popup behavior <div popover id=”options”> <h3>Replace image</h3> <button>Upload</button> <button>Browse</button> … </div> L TA EN IM R PE EX // add a toggle button

Slide 107

Slide 107

<div popover=”async” id=”statusMessage”> </div> L TA EN IM R PE EX // make an async popup

Slide 108

Slide 108

<div popover=”async” id=”statusMessage”> </div> const statusMessage = document.querySelector(“#options”); L TA EN IM R PE EX // make an async popup

Slide 109

Slide 109

<div popover=”async” id=”statusMessage”> </div> const statusMessage = document.querySelector(“#options”); // do publishing magic, then: statusMessage.textContent = “This document was published”; statusMessage.showPopover(); L TA EN IM R PE EX // make an async popup

Slide 110

Slide 110

L TA EN IM R PE EX popover browser support Experimental, behind lags, known accessibility issues about: lags, “Experimental Web Features” f f @hdv

Slide 111

Slide 111

@hdv We want your thoughts! @OpenUICG on Twitter Discord / weekly meetings f https://hidde.blog/dialog-modal-popover-di ferences/

Slide 112

Slide 112

@hdv We want your thoughts! @OpenUICG on Twitter Discord / weekly meetings

Slide 113

Slide 113

@hdv Wrapping up

Slide 114

Slide 114

markup affects accessibility trees

Slide 115

Slide 115

markup affects accessibility trees some of this is coming to JavaScript land

Slide 116

Slide 116

markup affects accessibility trees some of this is coming to JavaScript land some of this may be built into new html elements

Slide 117

Slide 117

@hdv thankS for listening! Contact/resources talks.hiddedevries.nl @hdv@front-end.social or hidde@sanity.io Special thanks for clari cations, input, feedback Mason Freed, Scott O’Hara, Julia Silver, Eric Eggert, all at Open UI CG fi Typefaces Bungee by David Jonathan Ross (DJR) Rasa by Anna Giedryś, David Březina (Rosetta)