You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-display-3] Clarify whether display: contents applies to ::before and ::after #1345
I have a (probably bitrotted already) implementation for this in Blink, but I talked about this with @dbaron a while ago and asked me to file this in order to clarify it, given Gecko doesn't implement it.
Gecko always treats display: contents in ::before and ::after as display: inline. It's not clear to me whether display: contents in pseudo-elements is really useful at all, and the implementation is complex.
It's not much clear, but browsers seem to believe that display: contents should join different texts into a single run of text (#1281). Then, in the following example, "FooBar" would be a single flex item:
So in this case whether ::before and ::after support display: contents or not is observable by other means than box-related properties on the pseudo-elements.
I think display: contents should apply to these pseudo-elements.
...should be completely indistinguishable as far as CSS is concerned. There is no reason for the two to diverge in any way.
That said, I also wouldn't be too sad if we defined that it didn't work. It's just inconsistent and breaks a constant that has nicely applied to ::before and ::after previously.
The CSS Working Group just discussed https://github.com/w3c/csswg-drafts/issues/1345, and agreed to the following resolutions:
RESOLVED: display:contents applies to ::after and ::before
The full IRC log of that discussion
<myles> TOPIC: https://github.com//issues/1345
<myles> Github topic: https://github.com//issues/1345
<myles> s/write/right/
<myles> fantasai: <restates the topic>
<myles> fantasai: TabAtkins and i are leaning toward "yes" but we aren't particularly resolute
<myles> fantasai: any opinions/
<myles> fantasai: ?
<myles> Rossen: it is unclear, if we say "no," what is observable?
<myles> fantasai: you can put a border on ::after, and the border will disappear if you say display:contents
<myles> fantasai: because the box will disappear
<myles> Rossen: was this just an oversight?
<myles> fantasai: just needed clarification
<myles> Rossen: this works for us
<myles> Rossen: objections?
<myles> RESOLVED: display:contents applies to ::after and ::before
Activity
Loirooriol commentedon May 10, 2017
It's not much clear, but browsers seem to believe that
display: contentsshould join different texts into a single run of text (#1281). Then, in the following example, "FooBar" would be a single flex item:So in this case whether
::beforeand::aftersupportdisplay: contentsor not is observable by other means than box-related properties on the pseudo-elements.I think
display: contentsshould apply to these pseudo-elements.tabatkins commentedon May 10, 2017
As @Loirooriol points out, it definitely has an observable effect, and is straightforward to define. Basically, the following two bits of markup:
and
...should be completely indistinguishable as far as CSS is concerned. There is no reason for the two to diverge in any way.
That said, I also wouldn't be too sad if we defined that it didn't work. It's just inconsistent and breaks a constant that has nicely applied to ::before and ::after previously.
css-meeting-bot commentedon May 24, 2017
The CSS Working Group just discussed
https://github.com/w3c/csswg-drafts/issues/1345, and agreed to the following resolutions:RESOLVED: display:contents applies to ::after and ::beforeThe full IRC log of that discussion
<myles> TOPIC: https://github.com//issues/1345<myles> Github topic: https://github.com//issues/1345
<myles> s/write/right/
<myles> fantasai: <restates the topic>
<myles> fantasai: TabAtkins and i are leaning toward "yes" but we aren't particularly resolute
<myles> fantasai: any opinions/
<myles> fantasai: ?
<myles> Rossen: it is unclear, if we say "no," what is observable?
<myles> fantasai: you can put a border on ::after, and the border will disappear if you say display:contents
<myles> fantasai: because the box will disappear
<myles> Rossen: was this just an oversight?
<myles> fantasai: just needed clarification
<myles> Rossen: this works for us
<myles> Rossen: objections?
<myles> RESOLVED: display:contents applies to ::after and ::before
tabatkins commentedon Jul 5, 2017
Closing as no change, because the WG decided to stick with it applying, and the effects of that just fall out of the definition.