[Web4lib] CSS3 selector question - nth-child(even)

Thomas Dowling tdowling at ohiolink.edu
Wed Dec 1 10:05:59 EST 2010


Greetings--

Attempting to do my six impossible things before breakfast, I ran up
against a CSS3 problem.  Or more likely, a dissonance between how I think
things should work and reality.

(More concise and less rambling example of the problem below at
<http://www.ohiolink.edu/~tdowling/even-test.html>).

I'm trying to display alternate entries in a list with a colored
background using the CSS3 'foo.bar:nth-child(even)' selector.  My
expectation was that, whatever else the page had, alternate occurrences of
'<foo class="bar">' would have the background.

Instead, I get the background on even-numbered <foo>'s *if* they happen to
be 'class="bar"'.  That's a very different thing if you have to work
around markup that may throw in other kinds of <foo>'s.

Am I simply trying to do something that can't be done?  FWIW, the
underlying HTML markup is generated by a third-party app and I can't
control the page in question.



-- 
Thomas Dowling
tdowling at ohiolink.edu





More information about the Web4lib mailing list