It’s Mid-2022 and Browsers (Mostly Safari) Still Break Accessibility via Display Properties

It was late 2020 when I last tested how browsers use CSS display properties to break the semantics of elements.

I had been waiting for Safari to fix how it handles display: contents for four years now, and was excited when the announcement came in June. Then I started testing the latest Safari Technical Preview and the results were not good. That prompted me to give each of Chrome, Firefox, and Safari a fresh run to see how they performed.

The following results are each set in a table with a numbered list following that provides more detail on any cells that are numbered:

Chrome 103 / Windows 11
CSS <tr>, <th>, <td> <ul>, <ol>, <dl> <h#> <button>
display: flex
display: grid
display: block
display: inline-block
display: contents 1 2
  1. <ol>s and <ul>s are not treated as lists, but <dl>s perform fine.
  2. Shows as a button in the accessibility inspector, but does not receive keyboard focus; cannot be navigated with JAWS 2022 button command (B); can be activated with a mouse, touch, and screen reader virtual cursor. 1366037
Firefox 102 / Windows 11
CSS <tr>, <th>, <td> <ul>, <ol>, <dl> <h#> <button>
display: flex 1,2
display: grid 1,2
display: block
display: inline-block 3
display: contents 3 4
  1. <th>s with flex and grid are exposed as cells, not headers. 1711273
  2. Using NVDA 2022.1, the table reports the wrong number of rows and columns and cannot be navigated with table navigation commands (Ctrl + Alt + ).
  3. Inserts text leaf between each list item; NVDA announces each item in the list when navigating by list (L).
  4. Shows as a button in the accessibility inspector, but does not receive keyboard focus; cannot be navigated with NVDA button command (B); can be activated with a mouse, touch, and screen reader virtual cursor; dev tools show a keyboard use warning. 1791648
Safari 15.6, Safari TP 148–153, Safari 16 / macOS 12.4–12.6
CSS <tr>, <th>, <td> <ul>, <ol>, <dl> <h#> <button>
display: flex 1
display: grid 1
display: block 1 2
display: inline-block 1 2
display: contents 1 2 3,4,5,6
  1. VoiceOver announces the wrong column and row count for each table; VoiceOver does not announce column headers when moving between columns; VoiceOver table navigation commands do not work (Ctrl + Option + + ). 239478, 239479
  2. VoiceOver does not announce ordered or unordered lists as lists (description lists are fine); VoiceOver does not navigate to ordered or unordered lists with list navigation (Ctrl + Option + + X). 243486, 243373
  3. Does not receive keyboard focus; cannot be navigated with VoiceOver button command (Ctrl + Option + + J); can be activated with a mouse. 243486
  4. As of Safari TP 151, can be navigated with VoiceOver button command (Ctrl + Option + + J) but its accessible name is not announced.
  5. As of Safari TP 152, its accessible name is announced.
  6. Safari 16 has regressed from Safari TP 152; the accessible name is not announced and it has none in the accessibility tree.
Chrome 103 / Android 12
CSS <tr>, <th>, <td> <ul>, <ol>, <dl> <h#> <button>
display: flex
display: grid
display: block
display: inline-block
display: contents 1
  1. <ol>s and <ul>s are not treated as lists, but <dl>s perform fine.
Safari / iPadOS 15.5
CSS <tr>, <th>, <td> <ul>, <ol>, <dl> <h#> <button>
display: flex
display: grid
display: block 1 2
display: inline-block 1 2
display: contents 1 2 3
  1. VoiceOver treats all cells as in column 1. 243474
  2. VoiceOver does not announce ordered or unordered lists as lists (description lists are fine).
  3. Fires on double-tap with VoiceOver.

Verdict

Chrome cleaned itself up and has held steady for more than 20 versions. Firefox needs work, but at least saw a tiny improvement. Safari made one tiny improvement but has a much bigger deficit, and I don’t trust it will improve much given its now twice-promised fix for display: contents.

Tests

The following four embedded CodePens are what I used for testing. These do not account for all scenarios or use cases, but at least provide a baseline set of results. They were all created in early 2020. I adapted them by adding horizontal rules between each test since VoiceOver was concatenating some elements with display: contents to the prior element.

Each links to a CodePen debug mode so you can test it directly, without the iframe or wrapper cruft.

HTML Tables

Visit the tables test in debug mode.

See the Pen Tables with Assorted Display Properties by Adrian Roselli (@aardrian) on CodePen.

Lists

Visit the lists test in debug mode.

See the Pen Lists with Assorted Display Properties by Adrian Roselli (@aardrian) on CodePen.

Headings

Visit the headings test in debug mode.

See the Pen Headings with Assorted Display Properties by Adrian Roselli (@aardrian) on CodePen.

Buttons

Visit the buttons test in debug mode.

See the Pen Buttons with Assorted Display Properties by Adrian Roselli (@aardrian) on CodePen.

References

I have not gone through all the old browser bugs, identified outstanding open bugs, nor filed fresh bugs. I just don’t have the energy. I am hoping readers can confirm or deny my findings, however, so if/when I muster that energy I have confirmation these issues aren’t just a failing on my end.

I have written about display properties, tables, and accessibility a bunch over the last few years. Others have also kicked in a pile of posts. This list is not exhaustive.

Update: 15 July 2022

I heard back from someone who works on WebKit (finally) and he confirmed the issues I found with the following bugs:

Update: 22 July 2022

I tested Safari Technology Preview 149 today. No change.

Update: 4 August 2022

I tested Safari Technology Preview 150 today on macOS 12.5. No change.

Update: 6 August 2022

More updates from Tyler Wilcock, namely that three commits have landed in WebKit that address the heading and button examples in this post:

I am thrilled to see the now-rapid progress from Tyler specifically. Compared to the current silence from Apple’s dedicated developer relations arm, past Apple mis-representation of fixes, and years of Apple’s failure to test for these obvious issues, this has been a breath of fresh air.

No idea which Safari Technical Preview will see these updates, but I am hopeful they will make it to Safari 16.

Update: 16 August 2022

I tested Safari Technology Preview 151 today on macOS 12.5.1. No change except a button with display: contents is now partially exposed in one context.

Update: 27 August 2022

I tested Safari Technology Preview 152 today. No change except a button with display: contents now has its accessible name announced.

Update: 11 September 2022

I tested Safari Technology Preview 153 today. No changes.

Update: 12 September 2022

I tested Safari 16 on macOS 12.6 today. It is equivalent to Safari TP 151. Tables with display properties are difficult to impossible to navigate with VoiceOver. Buttons with display: contents have no accessible name and do not activate on Enter. The minor improvements since Safari 15 (and before) are not enough to make buttons or tables accessibility supported on macOS. All this despite the following claim today:

Safari 16 introduces a re-architecture of WebKit’s accessibility support on macOS. […] Safari 16 also greatly improves accessibility support for elements with display:contents by ensuring they are properly represented in the accessibility tree.

And this claim in June 2022:

And this claim in March 2022:

WebKit fixed an accessibility bug with display:contents, which incorrectly hid content from the accessibility tree. This fix makes it possible to freely use this display value to remove a box from the DOM tree, while still including its children. This can be useful when you want to adjust which box is the child of a Flexbox or Grid container, for instance.

I really wish Apple had a dedicated Safari Twitter account instead of hanging its evangelist and/or the open source WebKit project out there to take the heat. That is unfair.

Remember that this is not an excuse to beat up the devs at Apple. If you are doing that, you are being unnecessarily mean to individuals who may have no control over broader organizational decisions. Do not be that guy / person / jerk.

Update: 13 September 2022

I filed an issue to update the Can I Use entry for display: block, and it was merged overnight: #6451: Safari 16 (release version) still broken

The Can I Use flex and grid data comes from the MDN browser-compat-data, so I filed an issue there: #17776 css.properties.display – Safari (thru 16) flex, grid, contents problems

Update: 17 September 2022

Apple’s devrel team came through and filed another PR at Can I Use (while still engaging me in my PR) and undid my changes. The good news is that for the first time Can I Use reflects that Safari 15.x and older never properly supported display: contents, acknowldegment of its prior false claims. The less good news is that both Apple and Can I Use believe that Safari supports display: contents when using it on buttons or tables renders them inaccessible in Safari 16. Clearly we have different ideas of the term supported.

Update: 20 September 2022

Following some informal community polling, Can I Use has restored Safari’s “partial support” entry for display: contents:

The Can I Use table for display contents showing Safari 16, 16.1, and TP all only partially support the feature.
CSS display: contents on Can I Use

My efforts have probably earned me no fans at Apple, though at least one Apple devrel person might agree with the change.

2 Comments

Reply

I encounter similar issues when I wish to set grid on the body element and display contents on the main element. The main issue I have is implementing a skip to content link that targets the main[display: contents] element :(
I think this should be of interest to the community since the following is a common DOM pattern:

Skipping the main element would really be a shame

Neil Osman; . Permalink
In response to Neil Osman. Reply

part of my comment was sanitized, so here is a demo that illustrates my point
https://codepen.io/WW3/pen/XWEVoqN

Leave a Reply to Neil Osman Cancel response

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>