Re: [css3-selectors] :contains

From: Lachlan Hunt <lachlan.hunt@iinet.net.au>
>
> Anne van Kesteren (fora) wrote:
>
> > 
> >>   Content generated with the ::before and ::after pseudo-elements does 
> >> not actually modify the content of the element; only the way it is 
> >> presented, and thus does not affect whether or not another selector 
> >> matches.  The background colour should be red.
> > 
> > 
> > I see. How about:
> > 
> > 
> >   <test/>
> > 
> >   test{                  background:red;
> >                          content:"PASS"  }
> >   test:contains('PASS'){ background:lime }
> > 
> > 
> > Personally, I don't see a difference here and I think that they all 
> > should have a green background (which stands for PASS, obviously). 
>
>    That's right, there is no difference.  The generated content doesn't 
> actually affect the contents of the element in the document, only the 
> way it is presented.  Thus, they all should be red.
>
> What about this:
> <test>foo</test>
>
> test:contains('foo') { content: 'bar' }
>
>    According to your logic, first the selector would match, the contents 
> would be changed, then it would no longer match, so it would be changed 
> back, then it would match again...

In addition, the definition of how to determine what matches :contains()
is quite explicit: "The textual contents of a given element is determined
by the concatenation of all PCDATA contained in the element and
sub-elements."  That definition is totally unaffected by anything that
styling does to the displayed content.

For example:
<test>foo<bar>baz</bar>bat</test>

bar {display:none}
test {background:red}
test:contains(baz) {background:blue}

would give the test element a blue background.

Received on Sunday, 30 May 2004 11:21:35 UTC