Skip to main content
26 events
when toggle format what by license comment
Jan 2, 2017 at 11:45 history closed Salman Arshad css Duplicate of CSS selector for first element with class
Jan 2, 2017 at 9:42 vote accept Jishnu V S
Jan 2, 2017 at 9:09 comment added BoltClock @mnemosdev: So in a ul with several li elements, li:first-child matches the first li. Whether ul:first-child matches that ul depends on whether that ul is the first child of its own parent, which is outside the scope of this question.
Jan 2, 2017 at 9:03 comment added BoltClock @mnemosdev: No, ul:first-child matches the ul in much the same way ul.example (with a class selector) matches the ul. It doesn't match other elements. Likewise, .red:first-child matches whichever element has the .red class, not its parent, or its child.
Jan 2, 2017 at 9:02 comment added 404answernotfound @BoltClock so ul:first-child would be the red class li and red:first-child would ref to itself?
Jan 2, 2017 at 8:59 comment added BoltClock @mnemosdev: It describes the child element relative to its parent. It does not describe the parent element.
Jan 2, 2017 at 8:58 comment added 404answernotfound isn't :first-child, :last-child, :nth-child referred to the parent element, in this case the ul element?
Jan 2, 2017 at 8:49 comment added Jishnu V S i have satisfied with comment of @Leo the lion
Jan 2, 2017 at 8:46 comment added BoltClock @Naila: Everyone has given you the answer but you seem dissatisfied. So it's not exactly clear what your real question is. Are you asking why :first-child isn't matching the first .blue element, or why it was designed that way?
Jan 2, 2017 at 8:44 answer added Alvaro timeline score: 6
Jan 2, 2017 at 7:51 comment added Leo the lion @Naila child is suppose to link to parent..in normal way if you have 1 son then if there will be any it will treated like nth son so there will be only first child in one parent.. you can have multi first child in one parent.. same logic is in coding implement..and bdw m not downvoter.
Jan 2, 2017 at 7:49 comment added Jishnu V S down voters please tell me the reason too
Jan 2, 2017 at 7:35 history edited Muhammad Omar ElShourbagy CC BY-SA 3.0
added 30 characters in body
Jan 2, 2017 at 7:33 comment added Mohammad Usman @Naila Here is the Official Documentation from W3 for pseudo selectors.
Jan 2, 2017 at 7:29 answer added amedina timeline score: 0
Jan 2, 2017 at 7:27 comment added Mohammad Usman Your selector .blue:first-child is not working because .blue is not first child of parent. This is the thinking behind implementation of this selector and as for me its quite logical.
Jan 2, 2017 at 7:27 comment added Jishnu V S @MuhammadUsman can you give me any reference please ?
Jan 2, 2017 at 7:25 comment added Mohammad Usman Problem exists in wrong understanding of :first-child or :last-child selector. They will select any element only when an element is first or last child element of its parent respectively.
Jan 2, 2017 at 7:23 answer added Dhaarani timeline score: 0
Jan 2, 2017 at 7:21 comment added Rahul Sharma exactly..i was talking on the behalf of <li>
Jan 2, 2017 at 7:21 comment added Jishnu V S that is last-child @RahulSharma
Jan 2, 2017 at 7:20 comment added Rahul Sharma third one <li class="red">three</li> should also change the color
Jan 2, 2017 at 7:20 comment added Rahul Sharma @Satpal: no its not working as expected...
Jan 2, 2017 at 7:19 comment added Satpal Its working as expected. <li class="blue">one</li> is not the first-child of parent ul
Jan 2, 2017 at 7:18 history edited dda CC BY-SA 3.0
deleted 13 characters in body; edited title
Jan 2, 2017 at 7:12 history asked Jishnu V S CC BY-SA 3.0