CSS Basic: First child and last child

How to use first child, last child and not in CSS

Ckmobile
Geek Culture

--

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:

Photo by Ben White on Unsplash
<!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>

--

--