Log in

View Full Version : Interpreting nth-of-type



blm126
05-18-2007, 01:34 AM
Hi, you guys. I've been messing around with using javascript to find elements based on CSS for a couple weeks now(to learn a little JS and CSS). You can see my progress here (http://code.google.com/p/findcss).Here's my question. Given the following HTML and CSS statement, what exactly is matched?


div > *:nth-of-type(1)



<div>
<div>Test tag</div>
<p>Test paragraph</p>
</div>

Will both tags be matched because they are both the first of their type, or will just the div match because the given tag is a wildcard? Hope you can help.

PS: Just for reference - http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#nth-of-type-pseudo

Twey
05-18-2007, 10:08 AM
Both will be matched. There's no reason to match only the <div>.

blm126
05-18-2007, 08:59 PM
Thanks Twey. That was what I was thinking, but the specs are very vague on this point.