Solved

:nth-child() CSS3 Selector

Posted on 2014-09-23
4
40 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Unordered lists (HTML ul tags) are very handy to create menus of all types, shapes and sizes.  All it takes is a little knowledge of CSS and the possibilities are endless. First off, you should know the general format for menus created using the …
When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
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 …

726 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