{"id":339318,"date":"2021-04-26T14:02:49","date_gmt":"2021-04-26T21:02:49","guid":{"rendered":"https:\/\/css-tricks.com\/?p=339318"},"modified":"2021-04-27T16:04:58","modified_gmt":"2021-04-27T23:04:58","slug":"exploring-color-contrast-for-the-first-time","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/exploring-color-contrast-for-the-first-time\/","title":{"rendered":"Exploring color-contrast() for the First Time"},"content":{"rendered":"\n
I saw in the release notes for Safari Technical Preview 122<\/a> that it has support for a color-contrast()<\/code> function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other browser ever will. But! It’s a very good idea! Any native tool to get us to ship more accessible interfaces (of which color contrast is a part) is cool by me. So let’s attempt to get it to work.<\/p>\n\n\n\n\n\n\n\n<\/figure><\/div>\n\n\n\nAnybody can download Safari Technical Preview<\/a>, so I did that. <\/p>\n\n\n\nI had to ask around about this, but just because this is a pre-release browser, it doesn’t mean all these features are active by default. Just as Chrome Canary has feature flags you have to turn on, so does Safari Technical Preview. So, I had to flip it on like this:<\/p>\n\n\n\n<\/figure>\n\n\n\nThe release notes don’t have any information about how to actually use color-contrast()<\/code>, but fortunately web searching turns up a spec (it’s part of Color Module 5<\/a>), and MDN has a page for it<\/a> with very basic syntax information. <\/p>\n\n\n\nThis is how I understand it:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat example above is a little silly, because it will always return white<\/code>\u2009\u2014\u2009that has the most contrast with black<\/code>. This function actually gets useful when one or more of those color values is dynamic<\/em>, meaning very likely it is a CSS custom property.<\/p>\n\n\n\nThe function returns a color, so the top use-case, I would guess, is going to be setting a color based on a dynamic background. So…<\/p>\n\n\n\nsection {\n background: var(--bg);\n color: color-contrast(var(--bg) vs white, black);\n}<\/code><\/pre>\n\n\n\nNow we can toss any color at all<\/strong> at --bg<\/code> and we’ll either get white or black text, depending on what has the most contrast:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
color-contrast()<\/code> function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other browser ever will. But! It’s a very good idea! Any native tool to get us to ship more accessible interfaces (of which color contrast is a part) is cool by me. So let’s attempt to get it to work.<\/p>\n\n\n\n\n\n\n\n<\/figure><\/div>\n\n\n\nAnybody can download Safari Technical Preview<\/a>, so I did that. <\/p>\n\n\n\nI had to ask around about this, but just because this is a pre-release browser, it doesn’t mean all these features are active by default. Just as Chrome Canary has feature flags you have to turn on, so does Safari Technical Preview. So, I had to flip it on like this:<\/p>\n\n\n\n<\/figure>\n\n\n\nThe release notes don’t have any information about how to actually use color-contrast()<\/code>, but fortunately web searching turns up a spec (it’s part of Color Module 5<\/a>), and MDN has a page for it<\/a> with very basic syntax information. <\/p>\n\n\n\nThis is how I understand it:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat example above is a little silly, because it will always return white<\/code>\u2009\u2014\u2009that has the most contrast with black<\/code>. This function actually gets useful when one or more of those color values is dynamic<\/em>, meaning very likely it is a CSS custom property.<\/p>\n\n\n\nThe function returns a color, so the top use-case, I would guess, is going to be setting a color based on a dynamic background. So…<\/p>\n\n\n\nsection {\n background: var(--bg);\n color: color-contrast(var(--bg) vs white, black);\n}<\/code><\/pre>\n\n\n\nNow we can toss any color at all<\/strong> at --bg<\/code> and we’ll either get white or black text, depending on what has the most contrast:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
Anybody can download Safari Technical Preview<\/a>, so I did that. <\/p>\n\n\n\nI had to ask around about this, but just because this is a pre-release browser, it doesn’t mean all these features are active by default. Just as Chrome Canary has feature flags you have to turn on, so does Safari Technical Preview. So, I had to flip it on like this:<\/p>\n\n\n\n<\/figure>\n\n\n\nThe release notes don’t have any information about how to actually use color-contrast()<\/code>, but fortunately web searching turns up a spec (it’s part of Color Module 5<\/a>), and MDN has a page for it<\/a> with very basic syntax information. <\/p>\n\n\n\nThis is how I understand it:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat example above is a little silly, because it will always return white<\/code>\u2009\u2014\u2009that has the most contrast with black<\/code>. This function actually gets useful when one or more of those color values is dynamic<\/em>, meaning very likely it is a CSS custom property.<\/p>\n\n\n\nThe function returns a color, so the top use-case, I would guess, is going to be setting a color based on a dynamic background. So…<\/p>\n\n\n\nsection {\n background: var(--bg);\n color: color-contrast(var(--bg) vs white, black);\n}<\/code><\/pre>\n\n\n\nNow we can toss any color at all<\/strong> at --bg<\/code> and we’ll either get white or black text, depending on what has the most contrast:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
I had to ask around about this, but just because this is a pre-release browser, it doesn’t mean all these features are active by default. Just as Chrome Canary has feature flags you have to turn on, so does Safari Technical Preview. So, I had to flip it on like this:<\/p>\n\n\n\n<\/figure>\n\n\n\nThe release notes don’t have any information about how to actually use color-contrast()<\/code>, but fortunately web searching turns up a spec (it’s part of Color Module 5<\/a>), and MDN has a page for it<\/a> with very basic syntax information. <\/p>\n\n\n\nThis is how I understand it:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat example above is a little silly, because it will always return white<\/code>\u2009\u2014\u2009that has the most contrast with black<\/code>. This function actually gets useful when one or more of those color values is dynamic<\/em>, meaning very likely it is a CSS custom property.<\/p>\n\n\n\nThe function returns a color, so the top use-case, I would guess, is going to be setting a color based on a dynamic background. So…<\/p>\n\n\n\nsection {\n background: var(--bg);\n color: color-contrast(var(--bg) vs white, black);\n}<\/code><\/pre>\n\n\n\nNow we can toss any color at all<\/strong> at --bg<\/code> and we’ll either get white or black text, depending on what has the most contrast:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
The release notes don’t have any information about how to actually use color-contrast()<\/code>, but fortunately web searching turns up a spec (it’s part of Color Module 5<\/a>), and MDN has a page for it<\/a> with very basic syntax information. <\/p>\n\n\n\nThis is how I understand it:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat example above is a little silly, because it will always return white<\/code>\u2009\u2014\u2009that has the most contrast with black<\/code>. This function actually gets useful when one or more of those color values is dynamic<\/em>, meaning very likely it is a CSS custom property.<\/p>\n\n\n\nThe function returns a color, so the top use-case, I would guess, is going to be setting a color based on a dynamic background. So…<\/p>\n\n\n\nsection {\n background: var(--bg);\n color: color-contrast(var(--bg) vs white, black);\n}<\/code><\/pre>\n\n\n\nNow we can toss any color at all<\/strong> at --bg<\/code> and we’ll either get white or black text, depending on what has the most contrast:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
color-contrast()<\/code>, but fortunately web searching turns up a spec (it’s part of Color Module 5<\/a>), and MDN has a page for it<\/a> with very basic syntax information. <\/p>\n\n\n\nThis is how I understand it:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat example above is a little silly, because it will always return white<\/code>\u2009\u2014\u2009that has the most contrast with black<\/code>. This function actually gets useful when one or more of those color values is dynamic<\/em>, meaning very likely it is a CSS custom property.<\/p>\n\n\n\nThe function returns a color, so the top use-case, I would guess, is going to be setting a color based on a dynamic background. So…<\/p>\n\n\n\nsection {\n background: var(--bg);\n color: color-contrast(var(--bg) vs white, black);\n}<\/code><\/pre>\n\n\n\nNow we can toss any color at all<\/strong> at --bg<\/code> and we’ll either get white or black text, depending on what has the most contrast:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
This is how I understand it:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat example above is a little silly, because it will always return white<\/code>\u2009\u2014\u2009that has the most contrast with black<\/code>. This function actually gets useful when one or more of those color values is dynamic<\/em>, meaning very likely it is a CSS custom property.<\/p>\n\n\n\nThe function returns a color, so the top use-case, I would guess, is going to be setting a color based on a dynamic background. So…<\/p>\n\n\n\nsection {\n background: var(--bg);\n color: color-contrast(var(--bg) vs white, black);\n}<\/code><\/pre>\n\n\n\nNow we can toss any color at all<\/strong> at --bg<\/code> and we’ll either get white or black text, depending on what has the most contrast:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
That example above is a little silly, because it will always return white<\/code>\u2009\u2014\u2009that has the most contrast with black<\/code>. This function actually gets useful when one or more of those color values is dynamic<\/em>, meaning very likely it is a CSS custom property.<\/p>\n\n\n\nThe function returns a color, so the top use-case, I would guess, is going to be setting a color based on a dynamic background. So…<\/p>\n\n\n\nsection {\n background: var(--bg);\n color: color-contrast(var(--bg) vs white, black);\n}<\/code><\/pre>\n\n\n\nNow we can toss any color at all<\/strong> at --bg<\/code> and we’ll either get white or black text, depending on what has the most contrast:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
white<\/code>\u2009\u2014\u2009that has the most contrast with black<\/code>. This function actually gets useful when one or more of those color values is dynamic<\/em>, meaning very likely it is a CSS custom property.<\/p>\n\n\n\nThe function returns a color, so the top use-case, I would guess, is going to be setting a color based on a dynamic background. So…<\/p>\n\n\n\nsection {\n background: var(--bg);\n color: color-contrast(var(--bg) vs white, black);\n}<\/code><\/pre>\n\n\n\nNow we can toss any color at all<\/strong> at --bg<\/code> and we’ll either get white or black text, depending on what has the most contrast:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
black<\/code>. This function actually gets useful when one or more of those color values is dynamic<\/em>, meaning very likely it is a CSS custom property.<\/p>\n\n\n\nThe function returns a color, so the top use-case, I would guess, is going to be setting a color based on a dynamic background. So…<\/p>\n\n\n\nsection {\n background: var(--bg);\n color: color-contrast(var(--bg) vs white, black);\n}<\/code><\/pre>\n\n\n\nNow we can toss any color at all<\/strong> at --bg<\/code> and we’ll either get white or black text, depending on what has the most contrast:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
The function returns a color, so the top use-case, I would guess, is going to be setting a color based on a dynamic background. So…<\/p>\n\n\n\n
section {\n background: var(--bg);\n color: color-contrast(var(--bg) vs white, black);\n}<\/code><\/pre>\n\n\n\nNow we can toss any color at all<\/strong> at --bg<\/code> and we’ll either get white or black text, depending on what has the most contrast:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
Now we can toss any color at all<\/strong> at --bg<\/code> and we’ll either get white or black text, depending on what has the most contrast:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
--bg<\/code> and we’ll either get white or black text, depending on what has the most contrast:<\/p>\n\n\n\n<\/figure>\n\n\n\nThat’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
That’s extremely cool<\/a>, even in the most basic use case.<\/p>\n\n\n\nHere’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\nCodePen Embed Fallback<\/iframe><\/div>\n\n\n\nJust picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
Here’s a demo from Dave where he’s not just setting the text color in the parent, but the color of links as well, and the links have a different set of colors to choose from. Play with the HSL sliders (in Safari Technology Preview, of course) to see it work.<\/p>\n\n\n\n
Just picking two colors that have enough contrast is easy enough (although you’d be surprised how often it’s screwed up by even those of us with good intentions). But oh wow does it get complicated quick<\/a> with different situations, let alone having a bunch of color variations, or god forbid, arbitrary combinations. <\/p>\n\n\n\nHere’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
Here’s a video of me playing with Dave’s tester so you can see how the colors update at different places. <\/p>\n\n\n\n<\/video><\/figure>\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
<\/p>\n","protected":false},"excerpt":{"rendered":"
I saw in the release notes for Safari Technical Preview 122 that it has support for a color-contrast() function in CSS. Safari is first out of the gate here. As far as I know, no other browser supports this yet and I have no idea when stable Safari will ship it, or if any other […]<\/p>\n","protected":false},"author":3,"featured_media":339322,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[18934,1372],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","jetpack-related-posts":[{"id":336679,"url":"https:\/\/css-tricks.com\/platform-news-prefers-contrast-mathml-is-and-css-background-initial-values\/","url_meta":{"origin":339318,"position":0},"title":"Platform News: Prefers Contrast, MathML, :is(), and CSS Background Initial Values","date":"March 19, 2021","format":false,"excerpt":"In this week\u2019s round-up, prefers-contrast lands in Safari, MathML gets some attention, :is() is actually quite forgiving, more ADA-related lawsuits, inconsistent initial values for CSS Backgrounds properties can lead to unwanted \u2014 but sorta neat \u2014 patterns. The prefers-contrast: more media query is supported in Safari Preview After prefers-reduced-motion in\u2026","rel":"","context":"In "Weekly Platform News"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/03\/wpn-20210319.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":343850,"url":"https:\/\/css-tricks.com\/meta-theme-color-and-trickery\/","url_meta":{"origin":339318,"position":1},"title":"Meta Theme Color and Trickery","date":"July 13, 2021","format":false,"excerpt":"Starting with Version 15, Safari supports the theme-color tag both on macOS and iOS. That\u2019s exciting news because now the first desktop browser supports this tag and it also supports the media attribute and the prefers-color-scheme media feature. I never really took much note of the theme-color meta\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/meta-theme-color.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":187180,"url":"https:\/\/css-tricks.com\/shape-blobbing-css\/","url_meta":{"origin":339318,"position":2},"title":"Shape Blobbing in CSS","date":"October 28, 2014","format":false,"excerpt":"We just covered shape morphing in SVG, where shapes change from one to another. Let's look at shapes that blob into each other! You know, that gooey squishy blobby effect like droplets of mercury on a surface. I'm not sure who first discovered this was possible on the web, but\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":345404,"url":"https:\/\/css-tricks.com\/safari-15-opinions\/","url_meta":{"origin":339318,"position":3},"title":"Safari 15 Opinions","date":"July 28, 2021","format":false,"excerpt":"It was interesting that when Safari 15 was dropping at this last WWDC, in my circles at least, I mostly heard enthusiasm. Like the colors-in-the-browser-controls stuff was a neat trick and fun to play with. And there were other more serious features, like iCloud Private Relay, which were near-universally applauded\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/07\/safari-15-tabs.jpg?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":339518,"url":"https:\/\/css-tricks.com\/is-vendor-prefixing-dead\/","url_meta":{"origin":339318,"position":4},"title":"Is Vendor Prefixing Dead?","date":"May 5, 2021","format":false,"excerpt":"Let\u2018s take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don\u2019t trigger PTSD for anyone! It\u2018s not clear who started prefixing, or when it began exactly. What is clear, is that by 2006, prefixed features were in Internet Explorer and\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/04\/prefixing-history.png?fit=988%2C506&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":342429,"url":"https:\/\/css-tricks.com\/safari-15-new-ui-theme-colors-and-a-css-tricks-cameo\/","url_meta":{"origin":339318,"position":5},"title":"Safari 15: New UI, Theme Colors, and… a CSS-Tricks Cameo!","date":"June 11, 2021","format":false,"excerpt":"There's a 33-minute video (and resources) over on apple.com covering the upcoming Safari changes we saw in the WWDC keynote this year in much more detail. Look who's got a little cameo in there: Perhaps the most noticeable thing there in Safari 15 on iOS is URL bar at the\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/06\/Screen-Shot-2021-06-11-at-8.20.24-AM.png?fit=1200%2C691&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"featured_media_src_url":"https:\/\/css-tricks.com\/wp-content\/uploads\/2021\/04\/color-contrast.svg","_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=339318"}],"version-history":[{"count":7,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions"}],"predecessor-version":[{"id":339538,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/339318\/revisions\/339538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/339322"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=339318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=339318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=339318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}