?
Solved

:nth-child() CSS3 Selector

Posted on 2014-09-23
4
Medium Priority
?
49 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 1000 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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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…
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

771 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