Why does the :nth-child(2) selector work on what I expect to be :first-child?
Posted
by
Ben
on Stack Overflow
See other posts from Stack Overflow
or by Ben
Published on 2012-03-19T17:18:44Z
Indexed on
2012/03/20
11:29 UTC
Read the original article
Hit count: 186
css
|css-selectors
I have an example of what I'm trying to ask.
I use this kind of format often. I'd expect to be able to select that first div with fieldset div:first-child { }
but it seems that it's only grabbed by the 2nd child selector. I would expect "field 1" to be red and not blue. It makes more sense semantically (to me at least) to say "style the first div in the fieldset like so" instead of saying the 2nd.
Why is this happening and is there a way to achieve the effect I want (to be able to call div:first-child)?
© Stack Overflow or respective owner