{"id":318216,"date":"2020-08-07T14:48:37","date_gmt":"2020-08-07T21:48:37","guid":{"rendered":"https:\/\/css-tricks.com\/?p=318216"},"modified":"2020-08-10T11:50:42","modified_gmt":"2020-08-10T18:50:42","slug":"nailing-the-perfect-contrast-between-light-text-and-a-background-image","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/nailing-the-perfect-contrast-between-light-text-and-a-background-image\/","title":{"rendered":"Nailing the Perfect Contrast Between Light Text and a Background Image"},"content":{"rendered":"\n

Have you ever come across a site where light text is sitting on a light background image? If you have, you’ll know how difficult that is to read. A popular way to avoid that is to use a transparent overlay<\/a>. But this leads to an important question: Just how transparent should<\/em> that overlay be? It\u2019s not like we\u2019re always dealing with the same font sizes, weights, and colors, and, of course, different images will result in different contrasts.<\/p>\n\n\n\n

Trying to stamp out poor text contrast on background images is a lot like playing Whac-a-Mole. Instead of guessing, we can solve this problem with HTML <canvas><\/code> and a little bit of math.<\/p>\n\n\n\n\n\n\n\n

Like this:<\/p>\n\n\n\n