CSS Basic: First child and last child
How to use first child, last child and not in CSS
Published in
2 min readAug 3, 2021
In this article, we are going to talk about how to select that specific element which is the first child and the last child of its parent.
Source code:
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>p:first-child{background-color: red;}p:last-child{background-color: blue;}li:last-child {background-color: lime;}</style></head>