topskill.dev
CoursesTracks
0
All courses/CSSField note color system
Modern CSS
1 / 6
← 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

Field note color system

The bluebird note repeats an accent color on its border and button. A CSS custom property lets you name that color once and reuse it.

:root selects the document's root element. A custom property starts with two hyphens: --accent: #e76f51. Other rules read it with var(--accent). The supplied --ink and --paper names work the same way. Custom-property names are case-sensitive. You can provide a missing-value fallback with var(--accent, #183153). A fallback does not repair every invalid value: if --accent exists but contains a value that is not a color, that color declaration can still fail. These properties inherit into the page's children, so the border and button can share them.

The button's transition: background-color 180ms ease describes a change: background-color is the property to animate, 180ms is the duration (milliseconds), and ease changes the pace rather than keeping a constant speed. Put the transition on the normal button rule so it works both when entering and leaving the highlighted state.

button:hover highlights the button under a pointer. button:focus-visible gives keyboard users the same color change and a visible outline. The button does not save a note; this lesson only styles it.

Try the demo

Change --accent in style.css, then Run Preview. Both the border and highlighted button should use the new color. Restore it. Hover the button, then use Tab to focus it and compare the highlight. The supplied reduced-motion query removes the transition when a visitor requests less motion; the next module explains that query in detail.

Hint 1
1 / 2
HINT 1

Keep the stylesheet linked from the document head.

HINT 2

Change one declaration at a time, then use Run Preview to inspect the result.

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