Complete the code to select every 3rd list item using the nth-child selector.
li[1] { color: blue; }The :nth-child(3n) selector matches every 3rd element (3rd, 6th, 9th, etc.).
Complete the code to select the 4th list item only.
li[1] { font-weight: bold; }The :nth-child(4) selector targets only the 4th element.
Fix the error in the selector to select every even list item.
li[1] { background-color: lightgray; }The :nth-child(even) selector matches every even-numbered element (2nd, 4th, 6th, etc.).
Fill BLANK_1 to select every 3rd list item starting from the 2nd (2,5,8...) with red color. Fill BLANK_2 to select every 3rd list item starting from the 1st (1,4,7...) with italic style.
li[1] { color: red; } li[2] { font-style: italic; }
:nth-child(3n+2) selects every 3rd element starting at 2nd (2, 5, 8...).:nth-child(3n+1) selects every 3rd element starting at 1st (1, 4, 7...).
Fill all three blanks to create a dictionary with CSS selectors as keys and colors as values: every 2nd item starting at 1st (odds: red) and every 2nd starting at 3rd (green).
const colors = {
"[1]": "[2]",
"[3]": "green"
};This creates an object with keys as selectors and values as colors.li:nth-child(2n+1) selects every 2nd item starting at 1 (1,3,5...).li:nth-child(2n+3) selects every 2nd item starting at 3 (3,5,7...).
Colors are assigned as strings.