topskill.dev
CoursesTracks
0
All courses/CSSPseudo-Elements
Selectors In Depth
5 / 7
← CSS
○CSS Rule Style an Exhibit Card○Write Your First CSS Rule○CSS Selectors Target Exhibit Details○Target Exhibit Details○Apply CSS Three Sources○Apply CSS Three Ways○Specificity Resolve a Style Conflict○Resolve Specificity○Inheritance and the cascade✦Module Quiz
○Color Palette○Color Palette○Background Layer○Background Layer○Type Rhythm○Type Rhythm○Borders and Shadows○Borders and Shadows✦Module Quiz
○Box Model Seed Packet Card○Space a Seed Packet○Display Swap Table Labels○Arrange Swap Table Labels○Positioning Pickup Pin○Pin the Pickup Location○Sizing and Overflow○Size a Seed-Swap Notice○Sticky scroll headings✦Module Quiz
○Advanced Selectors Book Cart Sign○Target a Book Cart Sign○Pseudo-Classes Night Cart States○Style Night Cart States●Pseudo-Elements○Add a Book-Quote Mark✦Module Quiz
○Lantern Market navigation○Lantern Market navigation✦Module Quiz
○Community garden request card○Community garden request card✦Module Quiz
○Flex Direction○Flex Direction○Main-Axis Spacing○Main-Axis Spacing○Cross-Axis Alignment○Cross-Axis Alignment○Wrapping and Flex Items○Wrapping and Flex Items○Flexbox Navigation○Flexbox Navigation✦Module Quiz
○Grid Tracks○Grid Tracks○Grid Gaps○Grid Gaps○Grid Placement○Grid Placement○Responsive Grid○Responsive Grid✦Module Quiz
○River radio schedule○Harbor radio schedule✦Module Quiz
○Field note color system○Field note color system○Transforms○Rotate a Field Note○Resilient styles✦Module Quiz
○Kite festival signal○Garden festival signal✦Module Quiz
○Garden forecast○Harbor forecast○Fluid sizing○Fluid weather bulletin○Images that fit✦Module Quiz
○Seed inventory table○Tool checkout table✦Module Quiz
○Community maker profile○Maker profile sheet✦Module Quiz

Pseudo-Elements

: a note in the margin

The Moonlit Book Cart adds a decorative opening quote to a reader note. The note itself stays in index.html; the decoration comes from CSS.

A pseudo-class such as :first-child chooses an existing element by a condition. A pseudo-element such as ::before lets you style a piece associated with that element. Notice the two colons.

Read .card:first-child::before in parts: find a card that is its parent's first element child, then style the generated piece before its content. content: "“" supplies the opening quote. Without content, this ::before decoration is not generated. Its color styles the quote, not the whole card.

Keep essential words, labels, and instructions in HTML. Generated content is not a dependable substitute for accessible text, and a decorative quote should not carry information that the note needs to make sense.

Run the preview. Only the first card has a gold quote. In style.css, change ::before to ::after and run again: the mark moves after the note. Restore ::before, then try changing its color. Restore #fbbf24 before the exercise.

Hint 1
1 / 2
HINT 1

Change one CSS value, then run the preview.

HINT 2

Restore the original value before continuing.

Files
  • ⋄index.html
  • ⋄style.css
Loading editor…