Hello!
I propose to add a new CSS Code style recommendation on our HTML and CSS codestyle page:
Avoid using
display: contents
.
The support [3] of this value is not complete and changes wildly depending on browser versions.
As explained in [1], ‘display: contents’ could be a liability for accessibility in xwiki.
AFAIK, this value is useful especially in combination with display: grid
to have all the children in the grid even though they are wrapped in semantically relevant parents [4]. In some cases, using display: contents
would just make the parent disappear from the accessibility tree [2] and defeat the purpose of having a semantic HTML structure.
So far in xwiki-platform, we don’t use CSS display: grid
(we use bootstrap grid instead) and we don’t use display: contents
. I think it’s still necessary to write down this recommendation in order to avoid making a major accessibility regression without noticing it.
Note: As of now, using display: contents
will not systematically trigger a failure in our WCAG automated tests.
Sources:
- display: contents considered harmful – Eric Bailey
- Display: Contents Is Not a CSS Reset — Adrian Roselli
- "display: contents" | Can I use... Support tables for HTML5, CSS3, etc
- More accessible markup with display: contents | hidde.blog – this article is not perfect, I recommend to take it with a grain of salt. It lacks some actual tests of the functionalities, see the comments made about it in [1].