Hiding content

A presentation at Rotterdam The Hague Front-end Meetup in June 2017 in Rotterdam, Netherlands by Hidde de Vries

Slide 1

Slide 1

Hiding
content Hidde de Vries / @hdv / DEPT, Rotterdam / 21-06-2017

Slide 2

Slide 2

Slide 3

Slide 3

Slide 4

Slide 4

Slide 5

Slide 5

People centered development

Slide 6

Slide 6

This is actually an accessibility talk

Slide 7

Slide 7

Physical
accessibility

Slide 8

Slide 8

Tactile paving

Slide 9

Slide 9

Elevator

Slide 10

Slide 10

Digital accessibility

Slide 11

Slide 11

Colour

Slide 12

Slide 12

Language

Slide 13

Slide 13

Code

Slide 14

Slide 14

When you send your
markup to the browser, it generates two trees (amongst others)

Slide 15

Slide 15

DOM tree

Slide 16

Slide 16

DOM tree

Slide 17

Slide 17

Accessibility tree

Slide 18

Slide 18

Accessibility tree

Slide 19

Slide 19

https://www.paciellogroup.com/resources/aviewer/ https://chrome.google.com/webstore/detail/accessibility-developer-t/fpkknkljclfencbdbgkenhalefipecmb

Slide 20

Slide 20

Slide 21

Slide 21

role = link

Slide 22

Slide 22

Slide 23

Slide 23

Slide 24

Slide 24

role = alert role = link role = button role = checkbox role = tab role = radio role = dialog role = progressbar role = slider role = tooltip https://www.w3.org/TR/using-aria/

Slide 25

Slide 25

Properties

Slide 26

Slide 26

Labels

Slide 27

Slide 27

States

Slide 28

Slide 28

Hiding
content

Slide 29

Slide 29

Hiding
content 1. Visually hiding 2. Hiding from AT 3. Really hiding 4. Inertifying

Slide 30

Slide 30

Visually hiding

Slide 31

Slide 31

You want text to be present for machines, but don’t want to see it
on the screen.

Slide 32

Slide 32

Contextual cues 
 to supplement
visual cues

Slide 33

Slide 33

[visually hiding] can resolve some of the tension between the demands of accessibility and the demands of visual design http://webaim.org/techniques/css/invisiblecontent/

Slide 34

Slide 34

Navigation heading EXAMPLE

Slide 35

Slide 35

Navigation heading EXAMPLE About us Products Projects Contact

Slide 36

Slide 36

Navigation heading EXAMPLE About us Products Projects Contact

Slide 37

Slide 37

Icon button EXAMPLE

Slide 38

Slide 38

Icon button EXAMPLE Please accept our cookie policy OK ×

Slide 39

Slide 39

Icon button EXAMPLE Please accept our cookie policy OK ×

Slide 40

Slide 40

Required indicator EXAMPLE

Slide 41

Slide 41

Required indicator EXAMPLE First name *

Slide 42

Slide 42

Required indicator EXAMPLE First name *

Slide 43

Slide 43

Hide label and rely on placeholder instead EXAMPLE

Slide 44

Slide 44

Hide label and rely on placeholder instead EXAMPLE

Name

Slide 45

Slide 45

Hide label and rely on placeholder instead EXAMPLE

Name

Slide 46

Slide 46

Hide label and rely on placeholder instead EXAMPLE

Name AVOID

Slide 47

Slide 47

text-indent: -9999em;

Slide 48

Slide 48

width: 0; and/or height: 0;

Slide 49

Slide 49

position: absolute; clip: rect(1px, 1px, 1px, 1px);

Slide 50

Slide 50

position: absolute; left: -9999em;

Slide 51

Slide 51

Visually hiding Element still shows up in the accessibility tree.

Slide 52

Slide 52

Visually hiding Element still shows up in the accessibility tree.

Slide 53

Slide 53

Hiding only from screenreaders

Slide 54

Slide 54

You want text to be invisible only for users of Assistive Technology

Slide 55

Slide 55

Repeating text that hinders AT users EXAMPLE

Slide 56

Slide 56

Repeating text that hinders AT users EXAMPLE Our company won a prize We are very proud to announce that we were nominated for an amazing price and that we have actually won it, too. Read more We opened a new office With the great opening party that took place yesterday, it is now official: our
new office in Utrecht is open! Read more We’ll be at the trade show The trade show is taking place next week and we will be presenting interesting new stuff. Visit our booth! Read more

Slide 57

Slide 57

Repeating text that hinders AT users EXAMPLE Our company won a prize We are very proud to announce that we were nominated for an amazing price and that we have actually won it, too. Read more We opened a new office With the great opening party that took place yesterday, it is now official: our
new office in Utrecht is open! Read more We’ll be at the trade show The trade show is taking place next week and we will be presenting interesting new stuff. Visit our booth! Read more Read more Read more Read more

Slide 58

Slide 58

aria-hidden

Slide 59

Slide 59

<div aria-hidden></div>

Slide 60

Slide 60

If you find you have to use aria-hidden , this may indicate there’s something wrong with the page

Slide 61

Slide 61

Repeating text that hinders AT users EXAMPLE Our company won a prize We are very proud to announce that we were nominated for an amazing price and that we have actually won it, too. Read more We opened a new office With the great opening party that took place yesterday, it is now official: our
new office in Utrecht is open! Read more We’ll be at the trade show The trade show is taking place next week and we will be presenting interesting new stuff. Visit our booth! Read more

Slide 62

Slide 62

Hiding from AT Element shows it is in the aria-hidden state.

Slide 63

Slide 63

Hiding from AT Element shows it is in the aria-hidden state.

Slide 64

Slide 64

(on purpose) Really hiding

Slide 65

Slide 65

You don’t want anyone to know about the content and make it invisible to all

Slide 66

Slide 66

A modal panel that is not currently shown EXAMPLE

Slide 67

Slide 67

A modal panel that is not currently shown EXAMPLE Perhaps the most heavily-repeated pattern in JavaScript-based page manipulation is showing and hiding content. Tabbed interfaces. Collapsible elements. Accordion widgets. It crops up nearly everywhere. In and of itself, this pattern is not a bad thing, but few people realize how profoundly your choice of hiding mechanism can influence the accessibility of your content to assistive technologies like screen readers. When building custom JavaScript-based widgets, it’s quite easy to fully control the hiding mechanism, but when you begin working with animation libraries like jQuery or Scriptaculous, the hiding mechanism is typically dictated by the library, leaving you little control over the accessibility of your Are you sure? NO YES

Slide 68

Slide 68

A tab control that 
 is closed EXAMPLE

Slide 69

Slide 69

A tab control that 
 is closed EXAMPLE

  1. Personal details 
 
 
 
 

  2. Your application
  3. Agreement
  4. Summary 







Slide 70

Slide 70

visibility: hidden;

Slide 71

Slide 71

display: none;

Slide 72

Slide 72

hidden

Slide 73

Slide 73

<div hidden></div>

Slide 74

Slide 74

Slide 75

Slide 75

Not exposed to a11y tree Not rendered Invisible to text search

Slide 76

Slide 76

Really hiding Element shows as ‘not exposed’ / ‘not rendered’

Slide 77

Slide 77

Really hiding Element shows as ‘not exposed’ / ‘not rendered’

Slide 78

Slide 78

Inert

Slide 79

Slide 79

inert https://github.com/WICG/inert https://html.spec.whatwg.org/multipage/interaction.html#inert

Slide 80

Slide 80

Makes the element and its entire subtree inert

Slide 81

Slide 81

No pointer events. No focus. Invisible to text search. Impossible to select.

Slide 82

Slide 82

Rest of the page while modal is open (“<dialog> without <dialog>” – Hixie ) EXAMPLE

Slide 83

Slide 83

Rest of the page while modal is open (“<dialog> without <dialog>” – Hixie ) EXAMPLE Perhaps the most heavily-repeated pattern in JavaScript-based page manipulation is showing and hiding content. Tabbed interfaces. Collapsible elements. Accordion widgets. It crops up nearly everywhere. In and of itself, this pattern is not a bad thing, but few people realize how profoundly your choice of hiding mechanism can influence the accessibility of your content to assistive technologies like screen readers. When building custom JavaScript-based widgets, it’s quite easy to fully control the hiding mechanism, but when you begin working with animation libraries like jQuery or Scriptaculous, the hiding mechanism is typically dictated by the library, leaving you little control over the accessibility of your Are you sure? NO YES

Slide 84

Slide 84

Rest of the page while modal is open (“<dialog> without <dialog>” – Hixie ) EXAMPLE Perhaps the most heavily-repeated pattern in JavaScript-based page manipulation is showing and hiding content. Tabbed interfaces. Collapsible elements. Accordion widgets. It crops up nearly everywhere. In and of itself, this pattern is not a bad thing, but few people realize how profoundly your choice of hiding mechanism can influence the accessibility of your content to assistive technologies like screen readers. When building custom JavaScript-based widgets, it’s quite easy to fully control the hiding mechanism, but when you begin working with animation libraries like jQuery or Scriptaculous, the hiding mechanism is typically dictated by the library, leaving you little control over the accessibility of your Are you sure? NO YES

Slide 85

Slide 85

Non current
carousel items EXAMPLE Now playing ➜ ➜

Slide 86

Slide 86

Non current
carousel items EXAMPLE Now playing ➜ ➜

Slide 87

Slide 87

Non current
carousel items EXAMPLE Now playing ➜ ➜

Slide 88

Slide 88

‘Shipping address’ section when ‘Same as billing address’ is checked EXAMPLE

Slide 89

Slide 89

‘Shipping address’ section when ‘Same as billing address’ is checked EXAMPLE Billing address Shipping address ✔ Same as billing address Street
* Postal code
* City
*

Street *

Postal code *

City *

Slide 90

Slide 90

Hiding
content 1. Visually hiding 2. Hiding from AT 3. Really hiding 4. Inertifying

Slide 91

Slide 91

Further reading http://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html

Slide 92

Slide 92

Questions? @hdv / hidde@hiddedevries.nl