W3C home > Mailing lists > Public > www-style@w3.org > May 2004

Re: [css3-selectors] :contains

From: Ernest Cline <ernestcline@mindspring.com>
Date: Sun, 30 May 2004 11:21:30 -0400
Message-ID: <410-220045030152130187@mindspring.com>
To: "Anne van Kesteren (fora)" <fora@annevankesteren.nl>
Cc: "W3C CSS List" <www-style@w3.org>




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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:30 GMT