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

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