Re: [csswg-drafts] [css-pseudo] Add a ::contents pseudo-element

> One of the reasons I keep pushing back on proposals like this is because they break cascading

*Instead* of having a pseudo element, why not introduce a new type of selector that ***targets only text contents as if it was a wrapped by a tag*** (directly above or below tag selector specificity).

Let's apply all of those selectors/properties one by one from top to bottom, with `@text` having more specificity than `*` but less than any specific tags; the comments list what happens with the text contents:

```css
section { color: red; }
/* red in section */
section * { color: blue; }
/* blue in section & sub-elems */
section { color: green; }
/* green in section, still blue in all sub-elms */
section p { color: orange; }
/* green in section, still blue in all sub-elms but orange in p as sub-elem */
section @text { color: yellow; }
/* yellow in section and sub-elems but orange in p as sub-elem */
section > @text { color: purple; )
/* purple in section, yellow in sub-elems but orange in p as sub-elem */
```
...etc.

Obviously applying display modes such as block, list, table, flex, grid would create one block context per combo-wrap of text nodes, inline and inline-block elements. By doing so you can mix in say a, span, abbr, code, etc elems. nth-child() etc. would work on those virtual elements, too.

Is there already a `display` mode for text? is inline fitting 100%.

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

Received on Thursday, 8 March 2018 17:53:11 UTC