Add a ::before marker to .text and colour the paragraph red.
Acceptance criteria
- 1.Add a ::before marker to .text and colour the paragraph red.
CSS Tutorial · CSS Selectors
These 10 tasks go with the CSS Pseudo Elements 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 Elements are used to style specific parts of an HTML element.” Read the chapter.
1.Add content beforeexercise · easy · 10 min
Add a ::before marker to .text and colour the paragraph red.
Passes when: Add a ::before marker to .text and colour the paragraph red.
2.Give the pseudo-element a colourexercise · easy · 10 min · practice plan
Colour .text green so its ::before inherits it.
Passes when: Colour .text green so its ::before inherits it.
3.Add content afterexercise · easy · 10 min · practice plan
Append a marker after .text and colour the element blue.
Passes when: Append a marker after .text and colour the element blue.
4.Use an empty content valueexercise · easy · 10 min · practice plan
Create a decorative box with empty content and a red parent.
Passes when: Create a decorative box with empty content and a red parent.
5.Style the first lineexercise · medium · 10 min · practice plan
Use ::first-line and colour the paragraph green.
Passes when: Use ::first-line and colour the paragraph green.
6.Fix the missing contentbug fix · easy · 8 min
Without content the pseudo-element never renders — colour the element green.
Passes when: Without content the pseudo-element never renders — colour the element green.
7.Fix the misspelled pseudo-elementbug fix · easy · 8 min · practice plan
It is ::before, not ::bofore — and the paragraph should be blue.
Passes when: It is ::before, not ::bofore — and the paragraph should be blue.
8.Fix the wrong element targetedbug fix · easy · 8 min · practice plan
The rule styles the span but the paragraph was intended.
Passes when: The rule styles the span but the paragraph was intended.
9.Fix after used instead of beforebug fix · easy · 8 min · practice plan
The marker should trail the text and the element must be blue.
Passes when: The marker should trail the text and the element must be blue.
10.Fix the unquoted contentbug fix · easy · 8 min · practice plan
A content string must be quoted.
Passes when: A content string must be quoted.
Between them these tasks cover ::before and ::after, content property and ::first-line.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.