topskill.dev
CoursesTracks
0
All courses/CSSPseudo-Classes Night Cart States
Selectors In Depth
3 / 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-Classes Night Cart States

Pseudo-classes: night cart states

A reader needs to see which control will respond to the keyboard. This reservation panel uses pseudo-classes: a colon followed by a condition, such as :focus. They select an existing element in a particular state or position; they do not create another element.

.reserve-button:hover matches while a pointer rests on the button. .email:focus matches while the email field receives keyboard input. .reading-list li:first-child matches a list item that is its parent's first element child. That last condition comes from the HTML order, not from moving the pointer.

Find focus without a mouse

Run the preview, click a blank area inside it, and press Tab until the email field receives focus. The cyan outline shows where you would type. Press Tab again to reach Reserve, then Shift+Tab to go back. Keep the pointer away from the button while checking the keyboard path so hover does not disguise a missing focus style.

The supplied .reserve-button:focus-visible rule keeps a visible ring on the button when keyboard navigation needs one. Unlike :focus, :focus-visible lets the browser decide when to show that ring. Do not remove an outline without providing a visible replacement.

Hover over Reserve to see its amber background darken. In style.css, temporarily change the hover background to #b45309, run, and compare the two states. Restore #d97706. The first recommendation stays bold throughout because its position has not changed.

Hint 1
1 / 1
HINT 1

Focus appears after clicking or tabbing into the email field.

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