<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/using-light-dark-without-getting-caught-out-kiz26jcki" -->

---
title: Using light-dark() without getting caught out | daily.dev
description: Geoff Graham found that using light-dark() across CSS-Tricks may have cost some performance. Martin Underhill's fallback pattern is a plain declaration (color:...
canonical: https://daily.dev/posts/using-light-dark-without-getting-caught-out-kiz26jcki
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Using light-dark() without getting caught out | daily.dev
og:description: Geoff Graham found that using light-dark() across CSS-Tricks may have cost some performance. Martin Underhill's fallback pattern is a plain declaration (color:...
og:url: https://daily.dev/posts/using-light-dark-without-getting-caught-out-kiz26jcki
og:image: https://api.daily.dev/og/posts/kIz26jCkI.png
og:image:alt: Using light-dark() without getting caught out
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Using light-dark() without getting caught out

**[CSS-Tricks](https://daily.dev/sources/css_tricks)** · 4 min read · 0 upvotes · 0 comments

## Summary

Geoff Graham found that using light-dark() across CSS-Tricks may have cost some performance. Martin Underhill's fallback pattern is a plain declaration (color: black) followed by the light-dark() version. Graham defined two custom properties, --light-dark and --dark-light, built from a gray palette. Comparing light-dark() with prefers-color-scheme on the site, the media-query version was larger: 7.2% minified, 4.0% gzipped, 1.4% Brotli.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://css-tricks.com/using-light-dark-without-getting-caught-out>

## Questions this post answers

### What happens in browsers that don't support CSS light-dark() if I don't add fallbacks?

Browsers without light-dark() support typically fall back to black text on a white background in Light Mode, and white text on a dark grey background in Dark Mode. The colors may not match your design, but the page still looks fine. The recommended safeguard is a plain declaration like color: black placed before the light-dark() declaration.

_Developers shipping dark mode keep up with CSS support gotchas like this on daily.dev._

### Is CSS light-dark() smaller than using prefers-color-scheme media queries?

In one site's stylesheet, the light-dark() version was smaller. Minified, the media-query version was 7.2% larger (+12,262 B), gzipped 4.0% larger (+1,207 B), and Brotli 1.4% larger (+337 B). Under Brotli the gap is small, so light-dark() is mostly a developer-experience win rather than a major performance gain.

_Weighing CSS theming approaches against performance is a recurring topic for developers on daily.dev._

## Similar posts on daily.dev

- [A few ways of specifying per-theme colours in only CSS — Chris Morgan](https://daily.dev/posts/a-few-ways-of-specifying-per-theme-colours-in-only-css-chris-morgan-yeihwzack) · Lobsters · 0 upvotes · 0 comments
- [More Easy Light-Dark Mode Switching: light-dark\(\) is about to support images\!](https://daily.dev/posts/more-easy-light-dark-mode-switching-light-dark-is-about-to-support-images--koazaflkr) · Bram.us · 42 upvotes · 3 comments
- [Modern CSS theming with light-dark\(\), contrast-color\(\), and style queries](https://daily.dev/posts/modern-css-theming-with-light-dark-contrast-color-and-style-queries-xprsuoenj) · Una Kravets · 22 upvotes · 1 comments
- [Dark Mode CSS Variables: Theme Systems with light-dark\(\)](https://daily.dev/posts/dark-mode-css-variables-theme-systems-with-light-dark--jfhy7ptnk) · SitePoint · 72 upvotes · 2 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#css](https://daily.dev/tags/css)

[View this post on daily.dev](https://daily.dev/posts/using-light-dark-without-getting-caught-out-kiz26jcki)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Using light-dark() without getting caught out","url":"https://daily.dev/posts/using-light-dark-without-getting-caught-out-kiz26jcki","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/using-light-dark-without-getting-caught-out-kiz26jcki"},"datePublished":"2026-11-27T16:05:00.626Z","dateModified":"2026-11-27T16:05:25.205Z","description":"Geoff Graham found that using light-dark() across CSS-Tricks may have cost some performance. Martin Underhill's fallback pattern is a plain declaration (color:...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9ed148a48f801052fa10bb9bab1b7fe0?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9ed148a48f801052fa10bb9bab1b7fe0?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"CSS-Tricks","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"CSS-Tricks","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/css_tricks","url":"https://daily.dev/sources/css_tricks"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/using-light-dark-without-getting-caught-out-kiz26jcki","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,css","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"CSS-Tricks","item":"https://daily.dev/sources/css_tricks"},{"@type":"ListItem","position":3,"name":"Using light-dark() without getting caught out"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/using-light-dark-without-getting-caught-out-kiz26jcki#faq","mainEntity":[{"@type":"Question","name":"What happens in browsers that don't support CSS light-dark() if I don't add fallbacks?","acceptedAnswer":{"@type":"Answer","text":"Browsers without light-dark() support typically fall back to black text on a white background in Light Mode, and white text on a dark grey background in Dark Mode. The colors may not match your design, but the page still looks fine. The recommended safeguard is a plain declaration like color: black placed before the light-dark() declaration. Developers shipping dark mode keep up with CSS support gotchas like this on daily.dev."}},{"@type":"Question","name":"Is CSS light-dark() smaller than using prefers-color-scheme media queries?","acceptedAnswer":{"@type":"Answer","text":"In one site's stylesheet, the light-dark() version was smaller. Minified, the media-query version was 7.2% larger (+12,262 B), gzipped 4.0% larger (+1,207 B), and Brotli 1.4% larger (+337 B). Under Brotli the gap is small, so light-dark() is mostly a developer-experience win rather than a major performance gain. Weighing CSS theming approaches against performance is a recurring topic for developers on daily.dev."}}]}
```

