Styling a list item with no class

Hey guys,

Is it possible to style a list item with no class?

For example

<ul>
<li>first item needs one style</li>
<li>second item needs a different one</li>
</li>

Should I be using jQuery to do this?

Did you try something like li:first-child or li:nth-child(2) to target the elements in your css?

1 Like

No haven’t tried that. Would you just keep using nth-child(3) then nth-child(4) for the additional items?

1 Like

That’s awesome!! Thanks for the link

1 Like

If each one is styled uniquely, yes.
But you can style alternating between odd and even number, or every third, or fourth or whatever without having to set up every item.

1 Like

Woohoo it worked, amazing thank you so much!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.