Skip to main content
100%

HTML Color Names (Relative Lightness)

✓ Published0🌍 Public
PPhilippe Rivière
Last edited May 4, 2017
Created on May 4, 2017

This visualization displays all HTML named colors as labeled swatches, using the WCAG relative luminance formula `L = 0.2126 * rgb.r + 0.7152 * rgb.g + 0.0722 * rgb.b` to set text color. The code compares this value against the simpler `hsl.l` luminance, highlighting colors where the two formulas disagree on the optimal black-or-white label contrast. Built with D3.js version 3.5.5, it loads color names from a CSV, renders each as a floating styled div, and dynamically assigns text color. The data originates from the Wikipedia list of web colors.

AI-generated description

Colors that are changed by the new formula L = 0.2126 * rgb.r + 0.7152 * rgb.g + 0.0722 * rgb.b > 0.5 * 255, compared to just hsl.luminance > 0.5.


I wanted a programmatically friendly list of the HTML named colors found here: https://en.wikipedia.org/wiki/Web_colors

Built with blockbuilder.org

forked from <a href='http://bl.ocks.org/enjalot/'>enjalot</a>'s block: <a href='http://bl.ocks.org/enjalot/7c0fe907ba2010fed420'>HTML Color Names (Relative Lightness)</a>

forked from <a href='http://bl.ocks.org/enjalot/'>enjalot</a>'s block: <a href='http://bl.ocks.org/enjalot/f3aa070fd1d937f49ed1560c05220214'>HTML Color Names (Relative Lightness)</a>

mit Licensed

Similar vizzes