Solved

:nth-child() CSS3 Selector

Posted on 2014-09-23
4
31 Views
Last Modified: 2016-04-21
When trying to target a specific element to change its css in comparison with its like elements, I think 'why not use the :nth-child() selector?' However, sometimes it works for me and sometimes it does not. So I just have a couple questions:

What are the limitations of the :nth-child() selector?
What are good resources on learning about the :nth-child() selector?
0
Comment
Question by:Alyson Facha
4 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 250 total points
ID: 40340374
There is no limitations - don't know what kind of limitations you think there would be.
But note it is nth-child - so the element you are targetting has to be a direct child.

http://www.w3schools.com/cssref/sel_nth-child.asp
0
 
LVL 53

Assisted Solution

by:COBOLdinosaur
COBOLdinosaur earned 250 total points
ID: 40340412
Generally when I want to target specific elements within a structure I prefer to use nth-of-type so that I can insert additional tags that modify or extend the structure without requiring a re-calculation of offset values.

nth-child is much less flexible than nth-of-type and I only use it when I need very narrow targeting.

Cd&
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

30 Experts available now in Live!

Get 1:1 Help Now