Workshop › Traffic light › Step 6 of 12
All three lamps share one class, yet each needs its own color. :nth-child(n) picks the lamp by its position.
```css
.lamp:nth-child(1) {
background: red;
}
.lamp:nth-child(2) {
background: gold;
}
.lamp:nth-child(3) {
background: limegreen;
}
```.lamp:nth-child(1) is a lamp that is the first child of its parent; 2 and 3 are the next ones..lamp, so their background wins over the grey.Write the three rules under the .lamp rule.
Skills: Styling with CSS
← Stack them in the middle Turn them off →