:has(<n number of elements>)

Examples

An element contains at least 4 child elements

:has(:nth-child(4)) {…}

An element contains exactly 5 child elements

:has(:nth-child(5):last-child) {…}

Source.


This content originally appeared on DEV Community and was authored by avcat

Examples

An element contains at least 4 child elements

:has(:nth-child(4)) {...} 

An element contains exactly 5 child elements

:has(:nth-child(5):last-child) {...} 

Source.


This content originally appeared on DEV Community and was authored by avcat


Print Share Comment Cite Upload Translate Updates
APA

avcat | Sciencx (2025-08-20T11:40:58+00:00) :has(<n number of elements>). Retrieved from https://www.scien.cx/2025/08/20/hasn-number-of-elements/

MLA
" » :has(<n number of elements>)." avcat | Sciencx - Wednesday August 20, 2025, https://www.scien.cx/2025/08/20/hasn-number-of-elements/
HARVARD
avcat | Sciencx Wednesday August 20, 2025 » :has(<n number of elements>)., viewed ,<https://www.scien.cx/2025/08/20/hasn-number-of-elements/>
VANCOUVER
avcat | Sciencx - » :has(<n number of elements>). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/08/20/hasn-number-of-elements/
CHICAGO
" » :has(<n number of elements>)." avcat | Sciencx - Accessed . https://www.scien.cx/2025/08/20/hasn-number-of-elements/
IEEE
" » :has(<n number of elements>)." avcat | Sciencx [Online]. Available: https://www.scien.cx/2025/08/20/hasn-number-of-elements/. [Accessed: ]
rf:citation
» :has(<n number of elements>) | avcat | Sciencx | https://www.scien.cx/2025/08/20/hasn-number-of-elements/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.