Make the first .card red using :first-child.
Acceptance criteria
- 1.Make the first .card red using :first-child.
CSS Tutorial · CSS Selectors
These 10 tasks go with the CSS Pseudo Classes chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “CSS Pseudo Classes are used to define a special state of an HTML element.” Read the chapter.
1.Style the first childexercise · easy · 10 min
Make the first .card red using :first-child.
Passes when: Make the first .card red using :first-child.
2.Style by positionexercise · easy · 10 min · practice plan
Use :nth-child(1) to target the first card.
Passes when: Use :nth-child(1) to target the first card.
3.Exclude with :not()exercise · easy · 10 min · practice plan
Colour every div that is not #one blue.
Passes when: Colour every div that is not #one blue.
4.Style the first of a typeexercise · easy · 10 min · practice plan
Target the first paragraph inside #one.
Passes when: Target the first paragraph inside #one.
5.Combine two pseudo-classesexercise · medium · 10 min · practice plan
Target the first child that is not a paragraph.
Passes when: Target the first child that is not a paragraph.
6.Fix the single colon countbug fix · easy · 8 min
Pseudo-classes use one colon, but this one is misspelled.
Passes when: Pseudo-classes use one colon, but this one is misspelled.
7.Fix the zero-based indexbug fix · easy · 8 min · practice plan
:nth-child() counts from 1, not 0.
Passes when: :nth-child() counts from 1, not 0.
8.Fix the inverted :not()bug fix · easy · 8 min · practice plan
This excludes the wrong element.
Passes when: This excludes the wrong element.
9.Fix the wrong element targetedbug fix · easy · 8 min · practice plan
The rule picks the span; the first paragraph was intended.
Passes when: The rule picks the span; the first paragraph was intended.
10.Fix the double colonbug fix · easy · 8 min · practice plan
A double colon marks a pseudo-element, not a pseudo-class.
Passes when: A double colon marks a pseudo-element, not a pseudo-class.
Between them these tasks cover :first-child, :nth-child and :not().
Looking for a different chapter? See every practice set, or switch to the interview theory questions.