Skip to content

Conversation

Ank8284
Copy link

@Ank8284 Ank8284 commented May 15, 2025

  • There's some issue but adding one more example can help,
    p:nth-last-child(3) selects the third-to-last <p> element within its parent.'
  • Warning: Ensure proper syntax! :nth-of-type only works for elements of the same type.

Addition : Nth-of-Type Selector

Select an element based on its occurrence among siblings of the same type.

:nth-of-type(A)

Targets elements of the same type by their position within a parent, counting from the start. Similar to :nth-child, but it only considers siblings of the same type, not all child elements.


Example
p:nth-of-type(3)
This selects the third <p> element within its parent.

Ank8284 added 3 commits May 15, 2025 15:00
added "Nth-of-Type Selector"
final update, added one more example so, people will not make syntax error and adding one extra layer of information as at first due it was not working and were forced to use different way too solve this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant