Re: [csswg-drafts] [css-selectors-4] ::text / ::text-node pseudoelement

I have desired something like this several times when I have `<div>Foo: <textarea></textarea></div>` and I want to vertically center the text with the textarea via `vertical-align: middle`, but there is no way to select the text.

Always wrapping text runs inside new boxes may be a breaking change, e.g. boxes inside a flex container become flex items, so this would prevent sequences of text runs to be wrapped inside a single anonymous flex item. CSS Flexbox could discriminate boxes generated by `::text` from all the other ones, but this would be confusing and inconsistent.

It has also been suggested to inject the styles into anonymous boxes, but I think this is a bad idea because the cascade is supposed to happen in the element tree, and I prefer to avoid another fiasco like `::first-line`.

I think what makes more sense would be:

 - Text nodes (or sequences of text nodes?) in the DOM tree are wrapped inside a `::text` pseudo-element in the CSS element tree.
 - These `::text` pseudo-elements must act as if they were assigned `display: contents` via a rule in the UA origin. Therefore, they do not generate any boxes and are treated as if they had been replaced with their children, which would be the current behavior. ([There is precedence for this](
 - This must be possible to override via `display`, so they do generate boxes if desired. But maybe mark this at-risk.

GitHub Notification of comment by Loirooriol
Please view or discuss this issue at using your GitHub account

Received on Monday, 22 January 2018 15:56:13 UTC