Menu

I built a CMYK color polyfill for browsers
📰

I built a CMYK color polyfill for browsers

DEV Community: css·Franklin Strube·about 1 month ago
#9Ezsc2uI
#devtocss#devto#dev#cmyk#color
Long article (302 words) — no AI summary yet.
Reading 0:00
15s threshold

I've been working in the print/publishing space for nearly two decades now. Since as long as I can remember, it's always been RGB on the web and CMYK for printing. That's just the way light works .

Well, I'm happy to announce that I recently created a browser polyfill that brings CMYK to the web. This is a first because, despite having a spec, browsers have never supported the device-cmyk() color function .

How Does It Work?

Like all polyfills, you just drop the script into your page.

<script src= "https://cdn.jsdelivr.net/npm/device-cmyk@latest/dist/device-cmyk.polyfill.js" ></script>

Enter fullscreen mode

Exit fullscreen mode

Behind the scenes, it combs through all CSS styles ( <style> tags, <link> tags, and inline styles), then it replaces any instances of device-cmyk() with an equivalent rgba() color.

It also proxies the element.style.* properties and similarly rewrites them in-place.

Color Profile Support

Anyone who has worked with print designs knows that on-screen display can be tricky.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.