-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-content][css-pseudo][css-cascade] Does content:contents in pseudo affect inheritance? #1195
Comments
Each pseudo-element defines what its originating element is; that's what it inherits from. Nothing inherits from a pseudo-element (unless/until we allow nesting pseudo-elements).
(The |
Thanks, makes sense. However, it's not true that nothing inherits from a pseudo-element, there is ::first-line:
Precisely, there are some problems with this, please see #1097. Anyways, it's sad |
I don't think that's the only reason it should exist. What happened to using it as an alternative to sub-grids, for example? |
Sorry, I was thinking of 'display: contents'. |
One use case for having 'content:contents' on a pseudo (and 'content:none' on the original element), is that it turns the original element into a wrapper box, which can be useful sometimes. For instance, just of the top of my head, it would allow you to have two borders: one on the element, and one on the pseudo containing the content. |
And also interesting things like using |
That's a hack, tho - it only allows you to add a single wrapper, and it removes your ability to add ::before/::after to it. This isn't a reasonable justification for the value. |
That reasoning is true for all pseudo-elements. For instance, '::after' only lets you add a single box at the end of an element's content, and removes your ability to use ::after for some other purpose. One could also argue that most actual use of ::before and ::after are hacks. The "hacks" described above would be nearly as useful as ::before and ::after, in a wide variety of circumstances. |
Multiple ::afters has been discussed before. It's been rejected only for lack of strong use-cases; it's not seen as anything bad. I... don't think it's defensible to claim that the mentioned technique isn't a hack? It's abusing two completely unrelated abilities to achieve a third unrelated thing, and has a number of arbitrary limitations/drawbacks, not intrinsically linked to the thing being achieved, as a result. That's more or less the definition of a hack. |
Labeling it as a hack doesn't change the fact that most of what ::before and ::after are used for fit the same definition you give above, and they are also incredibly useful nonetheless. What you call "abuse" because it wasn't part of the original intent, I would call atomic capabilities that can be applied to a much wider set of design problems, where changing the markup to add elements isn't a practical alternative. |
I think the biggest problem with multiple ::afters was not the lack of use cases, but the problem of ordering.
I don't think this is an unsolvable problem, but I seem to remember that bumping into it showed that multiple afters was not as straightforward as previously expected, and that decrease people's enthusiasm for it enough that we've not touched it since. Am I misremembering? |
I think multiple "::after" pseudos is something authors want. But my point was that "only allows you to add a single [::after], and it removes your ability to add [another] ::after to it" has not stopped::after from being incredibly useful in a wide range of situations, and the same could be said about 'content:contents' and 'content:none' to create wrappers and/or siblings. |
CSS Content allows to move the actual contents of an element into the ::before or ::after pseudo-element.
How does this affect inheritance? Do the actual contents of the element still inherit from the element, or do they inherit from the pseudo-element?
For example:
Should Foo be green or red? On the one hand, CSS Cascade says
so maybe the span should inherit from the div and be red. On the other hand, CSS Pseudo says
Personally I would expect green, like if I had used
content: "Foo"
instead ofcontent: contents
.As far as I know, there is no implementation of this to test.
The text was updated successfully, but these errors were encountered: