eki-al eki-al - 11 months ago 32
CSS Question

difference between ul:last-child and ul :last-child

I am creating a tree with angular inspire by

https://codepen.io/philippkuehn/pen/QbrOaN with a recursive tamplate

I would like the last elements of my tree print as a columns.

The last

element is accessible with
li a:last-child
. But i didn't find the way to access to only the last

For explain my question title, i tried to access with

ul li:last-child

By some kind of mistake i put a space and i saw i didn't get the same result. (i set a background-color for helping)

ul li :last-child

What is the difference ? and as optional question, what could be the best way to access the last

ps: i am using sass


ul li:last-child selects the last li element inside the ul.

ul li :last-child selects the last element (it doesn't matter if it's a div, or p or any other) inside the li.

You can just use the first one.