I didn't learn this recently but I tend to forget it from time to time.
The nth-child() selector every now and then throws me off.
I don't know why but I always interpret it like "select the nth child of this element", when in reality is "select this element if it is also the nth child of its parent", to put it in code, let's say we have this structure:
If I want to select the first div with the class name "child", I always first write .parent:nth-child(1), then realize my mistake when the code is not working and rewrite it as .child:nth-child(1)
I didn't learn this recently but I tend to forget it from time to time.
The
nth-child()
selector every now and then throws me off.I don't know why but I always interpret it like "select the nth child of this element", when in reality is "select this element if it is also the nth child of its parent", to put it in code, let's say we have this structure:
If I want to select the first
div
with the class name "child", I always first write.parent:nth-child(1)
, then realize my mistake when the code is not working and rewrite it as.child:nth-child(1)
Wow...today I learned. Thank you ;)