HTML & CSS · Junior · Question 35 of 75

How do you make the last item of a list of any length red without JavaScript?

Explanation

:last-child matches an element that is the last child of its parent. There are also :last-of-type (last element of its type) and :nth-last-child(). nth-child(10) only works with exactly 10 items, and there is no ::last pseudo-element.

Further reading

Problem with a question

HTML & CSS · Junior · question 35

Test yourself

Take the HTML & CSS · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz