Is it possible to select a specific li
element within a dynamic HTML structure without knowing the exact number of ul
elements or li
elements in each?
From my understanding, neither :nth-child
nor :nth-of-type
can achieve this due to the elements needing to be siblings.
<div>
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Pear</li>
</ul>
<ul>
<li>Melon</li>
<li>Mango</li>
</ul>
<ul>
<li>Strawberry</li>
</ul>
</div>
With the structure being dynamic, is there a way to select the nth li
element on the page?
For reference, JsFiddle link: click here
I am implementing LESS - are there any features in LESS that could assist with this issue?
Update:
After discovering the CSS4 pseudo-class :nth-match
, it seems that it's not currently supported. This, along with the feedback received, reinforces the idea that achieving this task may not be feasible at present... :(