CSS color controls readability, brand feel, and interaction affordance. Prefer consistent tokenized palettes over random hex values.
Common formats
#1d4ed8(hex)rgb(29 78 216)/rgba(...)hsl(226 76% 48%)- Named colors for quick demos only
A11y warning
Color alone must not carry critical meaning. Pair with text/icons/states and maintain contrast ratios.
Important interview questions and answers
- Q: Why use design tokens for color?
A: They centralize theme changes and reduce inconsistent hard-coded values. - Q: What is a common color accessibility failure?
A: Low-contrast body text and subtle placeholder colors. - Q: Hex vs HSL — when to pick HSL?
A: HSL is often easier for systematic lightness/saturation tuning.
Pitfall: Check cascade order—author stylesheet loses to inline styles and !important surprises.