See how contrast-color() automatically chooses black or white text for a background color.
contrast-color()
Sample text
This text changes automatically to preserve the best available contrast.
Chosen color
CSS code
Your privacy on this site
We use cookies and local storage only with your permission. Essential ones keep the site working; analytics help us understand usage via Google Analytics. You can reject all optional data. Read more in the Privacy policy
Privacy preferences
Essential
Language preference, cookie choice, and basic site operation. These cannot be turned off.
Always on
Analytics
Google Analytics (anonymous visit and page metrics). If off, we do not load that service or use geolocation to suggest language.