menu_book Course Curriculum (CSS) expand_more
:first-child and :last-child
Learn :first-child and :last-child in CSS through one focused, topic-specific example.
:first-child and :last-child controls a specific part of CSS inside Selectors. The example applies the exact selector, property, value, at-rule, or layout mechanism named by the lesson so you can observe its effect without unrelated declarations hiding it.
When testing this rule, inspect both the matched element and the computed style. CSS bugs often come from cascade, containing-block, formatting-context, or intrinsic-size rules rather than from syntax alone.
Topic-specific example
.steps > li:first-child { border-radius: 1rem 1rem 0 0; }
.steps > li:last-child { border-radius: 0 0 1rem 1rem; }
Check the computed value for :first-child and :last-child; inherited, initial, percentage, and auto values may resolve differently from the text you authored.