W3C home > Mailing lists > Public > www-style@w3.org > July 2013

Re: [css-selectors] Selecting non-element nodes

From: Simon Sapin <simon.sapin@exyr.org>
Date: Fri, 26 Jul 2013 06:40:54 +0100
Message-ID: <51F20BE6.40704@exyr.org>
To: François REMY <francois.remy.dev@outlook.com>
CC: "www-style@w3.org" <www-style@w3.org>
Le 25/07/2013 19:13, François REMY a écrit :
> For some time already, people advocated for a way to select text nodes using CSS.
>
>
> Proposal:
>
>     :node-type(x) pseudo-class, whose absence implies the "element" type
>     { other values includes "all", "text", "comments"... }

For now, Selectors can only select elements and a small set of 
pseudo-elements.

In CSS stylesheets, it might, maybe, make sense to select and apply 
properties to "text", as if text runs between tags were wrapped in a 
"virtual element". But I don’t think it makes sense for any other type 
of node. What would it mean to apply properties to comments?

(Selector APIs are another story. There, the semantics could be closer 
to that of XPath.)


> Use cases include:
>
> - flowing text nodes into a css-region-flow while keeping some siblings out of the flow
>
>      .to-flow-into> *:node-type(all) { flow-into: x }
>      .to-flow-into> .not-in-flow { flow-into: none }
>
> - hiding text-nodes as part of the continuing content of a document
>
>      .read-more ~ *:node-type(all) {display:none})
>
> - coloring them without affecting the other elements inherited color value
>
>      .local-blue> *:node-type(text) { color: blue }

I’m not super convinced. It seems that these examples would be used 
between "block-level" siblings, where you rarely have "naked" text 
nodes. (Often, there is at least a <p> element.)

But that’s just my opinion.

-- 
Simon Sapin
Received on Friday, 26 July 2013 05:41:18 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:30 UTC