The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Different coloured LI elements?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #196003

    I want to have an unordered list with each LI element having it’s own background color.

    I know to do that using :child pseudoelement:

    ul li:nth-child(1){ background-color: #ffcc00;}
    ul li:nth-child(2){ background-color: #dddddd;}
    … so one.

    My question, if someone could answer, is as follow. There is an automated way to do that via CSS or donno, if it’s not possible at least via CSS and jquery? I use wordpress and for example if I want to make an list with 20 elements to avoid the case where I would have 20 CSS LI declarations.

    Thank you.


    My question would be “why all different colors?”.

    That would be a very distracting element on a webpage.

    How would the user know what colors mean what…do they even mean anything?

    Plus…in actuality you’d probably have to multiply the number by at least 3 to reflect the different states of the menu items.

    20 menu items…if you have that many I’d suggest you have bigger issues than color.

    I’d pick a simple palette and stick to it.


    I recall this being made not too long ago :


    There is no menu. I want to make top 10, top 5 lists …etc, the best( SF movie for example) being first with red background. And I plan to use light colour shades or rgba transparency.


    Thank you. That thing works. And I guess the problem is solved.


    Hello. Found a better way in therms of looks for my problem and for now skipped the multi colours part.
    I thought it would be nice to post a link with the final result.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘CSS’ is closed to new topics and replies.