topskill.dev
CoursesTracks
0
All courses/CSSAdvanced Selectors Book Cart Sign
Selectors In Depth
1 / 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

Advanced Selectors Book Cart Sign

Advanced selectors: book cart sign

The Moonlit Book Cart sign has a heading, a summary tucked inside a wrapper, and a sample link. You can target each part without giving every element a new class.

Follow the HTML relationships

A child sits one level inside its parent. A descendant can be several levels down. In index.html, the heading is a child of .book-card; the paragraph is inside .summary, so it is a descendant of the card but not its child.

In style.css, .book-card p uses a space to reach paragraphs anywhere inside the card. .book-card > h2 uses > to reach only direct child headings. The element on the right is the one being styled.

a[target="_blank"] uses square brackets to match an attribute value. It selects links whose target is _blank, not every link. The underline is a visual style; the HTML attribute controls where the link opens.

Compare two selectors

Run the preview. The nested summary is pale blue, the title is larger, and the sample link is gold and underlined. In style.css, change .book-card p to .book-card > p and run again. The paragraph loses its pale blue because its immediate parent is .summary. Restore the space before the next exercise.

Hint 1
1 / 1
HINT 1

A space selects descendants; > selects only direct children.

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