Why Hardcoding #d9d9d9 in CSS Breaks Dark Mode and Accessibility
The hex color #d9d9d9, a light gray commonly used for borders, disabled buttons, and card backgrounds, is one of the most frequently hardcoded values in CSS. Developers often treat it as a safe neutral, but this practice introduces significant UI bugs in production apps. In dark mode, the color's high lightness renders as a glaring bright element, disrupting the intended visual experience. It can also fail accessibility contrast standards and render inconsistently across color spaces like sRGB and Display P3. The recommended fix is to replace hardcoded hex values with semantic CSS variables or design tokens that adapt to the user's theme and display environment.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in