0

For example, in my theme, I have the following elements,

<ul>
<li> apple </li>
<li> orange </li>
<li> banana </li>
<li> pear </li>
<li> peach </li>
...
</ul>

I just want to display the first two li elements, how to hide the other ones form the third element?

The given condition to my issue is that, I cannot add any attribute like id or class to li elements.

0

You can css

ul li:nth-child(n+3) {
    display: none;
}

It'll not show 3rd and up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.