Solved

:nth-child() CSS3 Selector

Posted on 2014-09-23
4
27 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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

"I want to put my photos online, but I don't want them stolen.  What settings should I use?" When You Put Photos Online First and foremost, any digital file published on the WWW can be copied, stored, modified, retransmitted, etc.  Remember Naps…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

763 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

11 Experts available now in Live!

Get 1:1 Help Now