We can use
first-child
to select only the first child element:
.my-list li:first-child {
    background-color: red;
}
last-child
is used to select the last member from the list:
my-list li:last-child {
    background-color: blue;
}
nth-child(5)
is used to select
nth
element. In the example we select 5th element
.my-list li:nth-child(5) {
    background-color: yellow;
}
We can also use
nth-child(even)
to select even members from the list
.my-list li:nth-child(even) {
    background-color: grey;
}
by Valeri Tandilashvili
5 years ago
CSS
properties
CSS Crash Course For Absolute Beginners
1
Pro tip: use ```triple backticks around text``` to write in code fences