This topic has not yet been rated - Rate this topic

:nth-child pseudo-class

[This documentation is preliminary and is subject to change.]

Applies one or more styles to the element that is the n-th child of its parent element.

Selectors Level 3, Section 6.6.5.2

Syntax

selector:nth-child(an+b) {...}

Parameters

selector

A CSS simple selector.

an+b

Standards information

Remarks

The :nth-child pseudo-class is a structural pseudo-class. Structural pseudo-classes enable selection based on extra information in the document tree that cannot be selected using simple selectors or combinators.

See also

Reference
:root
:nth-last-child
:nth-of-type
:nth-last-of-type
:last-child
:first-of-type
:last-of-type
:only-child
:only-of-type
:empty

 

 

Build date: 3/13/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Does it work in IE?
Hint - it's IE.  You don't expect things to work in IE.
Does it work with IE < 9?
Not sure whether if work or not with IE 9. I'm using IE 8 and it seems to be not working, even in compatibility mode.
IE9 Support?
This doesn't really appear to work in IE9.  I have not had luck yet with it.
Not working in IE9
I tried it in IE9 with no luck (as the previous contributor mentioned as well). Doesn't seem to work under IE9. Seems like it's not implemented yet.
It works
You probably have additional child elements that it is counting as well. In that case, you should use "nth-of-type(an+b)"nth-child not only selects direct descendents, but child of child descendents as well.