Re: [csswg-drafts] [css-display][css-aam][selectors-4] How elements with `display:contents` get focused?

Currently, the spec is pretty clear that
> The `display` property has no effect on an element’s semantics... Aside from the `none` value, which also affects the aural/speech output _and interactivity_ of an element _and its descendants_, the `display` property **only affects visual layout**.

So if `display: contents` would affect the focusability of the element, it should at least be also listed as an exception, along with `display: none`. I'd argue that even affecting particular interactions (like making the element unreachable for the keyboard activation) should be explicitly listed as such exception (though I still hope that having such change in behavior just because of display change is not inevitable).

After re-reading the introduction part of the CSS Display, I have to admit that my understanding of CSS boxes generated by the pseudo-elements and text content as "associated" with the originating element was probably wrong (though using the more unambiguous wording in the HTML spec would still be less confusing:). However, the concept of pseudo-elements that _are_ rendered _despite their originated element being not rendered_ still seems very counter-intuitive to me.

More importantly, since the contents of the element with `display:contents` _can_ be interacted with in a way that normally makes the element focused (e.g. clicked), from both user's and author's perspective such element definitely _has_ parts of the element that could be a focus target, which fits well the definition of the _focusable area_. "Magically" making these parts non-focusable just because the element with its subtree is _rendered differently_ seems to violate the [Priority of Constituencies principle](https://www.w3.org/TR/html-design-principles/#priority-of-constituencies). That is the reason why I would still prefer considering `display:contents` a very special case of the off-screen _rendering_ rather than a strange case of being _not_ rendered (but still displayed and interactive, at least partially!). In my opinion, it would be less confusing and "paradoxical" if the term "not rendered" is used only when the element _and its subtree_ are completely and irrevocably removed from the visual presentation, like with `display: none`.

By the same reasoning, I'd prefer the focusability (and, ideally, the default focus selection) of the element being associated not with its primary box in the CSS box tree, but with the DOM element itself, and automatically (not "magically":) translated to the first displayed part of the element subtree (so the user would be able to tab to the button text, and this text would get the outline similar to the outline of the text link). But I agree that it's probably a separate issue, less important than the question if elements with `display:content` are focusable at all.

-- 
GitHub Notification of comment by SelenIT
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2632#issuecomment-439714211 using your GitHub account

Received on Sunday, 18 November 2018 18:27:33 UTC