Complete the code to select the first child element of a list.
ul li:[1] { color: red; }The :first-child selector targets the first child element inside its parent.
Complete the code to select the last paragraph inside a section.
section p:[1] { font-weight: bold; }The :last-child selector targets the last child element inside its parent.
Fix the error in the code to select the first list item correctly.
ol li:[1] { background-color: yellow; }The correct pseudo-class to select the first child is :first-child. :nth-child(1) also works but is less common for this purpose.
Fill both blanks to style the first and last list items with different colors.
ul li:[1] { color: green; } ul li:[2] { color: blue; }
:first-child selects the first item, and :last-child selects the last item in the list.
Fill all three blanks to style the first list item italic, the last list item bold, and all list items except the second one gray.
li:[1] { font-style: italic; } li:[2] { font-weight: bold; } li:not(:[3]) { color: gray; }
:first-child styles the first list item italic, :last-child styles the last bold, and :not(:nth-child(2)) styles all except the second item gray.