What I learned about nth-child selectors

Today I learned an interesting fact about how the nth-child CSS selector works and it was different to what I expected and what seems to make sense.
I had the following HTML snippet:
<div class="input-group"> <div class="legacy&…


This content originally appeared on Posts on LINQ to Fail and was authored by Posts on LINQ to Fail

Today I learned an interesting fact about how the nth-child CSS selector works and it was different to what I expected and what seems to make sense. I had the following HTML snippet: <div class="input-group"> <div class="legacy"> <div class="input-subgroup"> <input name="itemId" id="Type0" type="radio" checked="checked" value="1"> <label for="Type0">Single</label> </div> <div class="input-subgroup"> <input name="itemId" id="Type1" type="radio" value="2"> <label for="Type1">Couple</label> </div> <div class="input-subgroup"> <input name="itemId" id="Type2" type="radio" value="3"> <label for="Type2">Family</label> </div> </div> <div class="new"> <div class="input-subgroup"> <input name="somethingElse" id="somethingElse" type="text" maxlength="2" placeholder="Enter" value=""> </div> <div class="input-subgroup"> <input name="somethingElse2" id="somethingElse2" type="text" maxlength="2" placeholder="Enter" value=""> </div> </div> </div> And I wanted to find the input[type="radio"] at a particular position in the DOM.


This content originally appeared on Posts on LINQ to Fail and was authored by Posts on LINQ to Fail


Print Share Comment Cite Upload Translate
APA
Posts on LINQ to Fail | Sciencx (2023-11-28T23:07:29+00:00) » What I learned about nth-child selectors. Retrieved from https://www.scien.cx/2014/03/06/what-i-learned-about-nth-child-selectors/.
MLA
" » What I learned about nth-child selectors." Posts on LINQ to Fail | Sciencx - Thursday March 6, 2014, https://www.scien.cx/2014/03/06/what-i-learned-about-nth-child-selectors/
HARVARD
Posts on LINQ to Fail | Sciencx Thursday March 6, 2014 » What I learned about nth-child selectors., viewed 2023-11-28T23:07:29+00:00,<https://www.scien.cx/2014/03/06/what-i-learned-about-nth-child-selectors/>
VANCOUVER
Posts on LINQ to Fail | Sciencx - » What I learned about nth-child selectors. [Internet]. [Accessed 2023-11-28T23:07:29+00:00]. Available from: https://www.scien.cx/2014/03/06/what-i-learned-about-nth-child-selectors/
CHICAGO
" » What I learned about nth-child selectors." Posts on LINQ to Fail | Sciencx - Accessed 2023-11-28T23:07:29+00:00. https://www.scien.cx/2014/03/06/what-i-learned-about-nth-child-selectors/
IEEE
" » What I learned about nth-child selectors." Posts on LINQ to Fail | Sciencx [Online]. Available: https://www.scien.cx/2014/03/06/what-i-learned-about-nth-child-selectors/. [Accessed: 2023-11-28T23:07:29+00:00]
rf:citation
» What I learned about nth-child selectors | Posts on LINQ to Fail | Sciencx | https://www.scien.cx/2014/03/06/what-i-learned-about-nth-child-selectors/ | 2023-11-28T23:07:29+00:00
https://github.com/addpipe/simple-recorderjs-demo