W3C home > Mailing lists > Public > public-css-archive@w3.org > January 2018

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

From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
Date: Mon, 22 Jan 2018 15:56:07 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-359468226-1516636564-sysbot+gh@w3.org>
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](https://drafts.csswg.org/css-scoping/#slots-in-shadow-tree))
 - 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 https://github.com/w3c/csswg-drafts/issues/2208#issuecomment-359468226 using your GitHub account
Received on Monday, 22 January 2018 15:56:13 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:23 UTC