color‑scheme Meta Generator - Online Dark/Light Opt‑in
Generate the <meta name='color‑scheme'> tag and CSS property to enable native dark/light rendering. Quick copy.
UD5 Toolkit
/* Detect system color scheme */ @media (prefers-color-scheme: dark) { body { background-color: #1a1a2e; color: #e0e0e0; } } @media (prefers-color-scheme: light) { body { background-color: #ffffff; color: #1a1d23; } }
/* Tell browser which scheme to use */ :root { color-scheme: light dark; } .dark-theme { color-scheme: dark; --bg: #1e1e2e; --text: #e0e0e0; --surface: #2d2d3f; }
prefers-color-scheme?
prefers-color-scheme is a CSS media feature that detects whether the user has requested a light or dark color theme at the operating system level. It allows websites to automatically adapt their appearance to match the user's system preference, providing a seamless and comfortable viewing experience. The possible values are light, dark, and no-preference.
prefers-color-scheme?
prefers-color-scheme is widely supported across all modern browsers: Chrome 76+, Firefox 67+, Safari 12.1+, Edge 79+, and Opera 62+. It also works on mobile browsers including iOS Safari 13+ and Chrome for Android. Global browser support exceeds 97% as of 2025, making it safe for production use.
color-scheme and prefers-color-scheme?
prefers-color-scheme is a media query that detects the user's OS-level preference (read-only). color-scheme is a CSS property that tells the browser which color scheme an element should render with. Setting color-scheme: dark on an element makes native UI controls (inputs, selects, scrollbars, buttons) render in their dark variant. They work best together: use prefers-color-scheme to detect preference, and color-scheme to inform the browser how to render form elements.
Use window.matchMedia('(prefers-color-scheme: dark)') in JavaScript. This returns a MediaQueryList object with a matches boolean property. You can also listen for real-time changes using addEventListener('change', callback), which fires whenever the user toggles their system theme. This enables dynamic, instant theme switching without page reload.
This is often because the color-scheme CSS property hasn't been set. While prefers-color-scheme detects the system setting, native form controls won't automatically switch to dark styling unless you explicitly set color-scheme: dark on the :root or body element. Add :root { color-scheme: light dark; } to your global styles to enable automatic adaptation of native UI elements.
The best practice is a three-state toggle: Light, Dark, and Auto (follow system). Store the user's choice in localStorage and apply the appropriate class or attribute to the <html> element. Use CSS custom properties (variables) scoped to [data-theme="dark"] and [data-theme="light"] selectors for full control. In Auto mode, fall back to prefers-color-scheme media queries.
prefers-color-scheme in DevTools?
Yes! In Chrome DevTools, open the Command Menu (Cmd+Shift+P / Ctrl+Shift+P), type "Show Rendering," and in the Rendering tab you'll find an option to emulate prefers-color-scheme. In Firefox, open DevTools Settings and check "Enable prefers-color-scheme simulation." This tool above provides a live preview alternative without opening DevTools.
Indirectly, yes. Google considers Core Web Vitals and user experience as ranking factors. A well-implemented dark mode reduces eye strain, improves readability in low-light environments, and can increase time-on-page. Additionally, respecting user preferences signals good UX design. While prefers-color-scheme itself isn't a direct ranking signal, the improved engagement metrics can positively impact SEO.
Generate the <meta name='color‑scheme'> tag and CSS property to enable native dark/light rendering. Quick copy.
Start from a base color and use `oklch(from color l c h)` to create lighter or darker variants. Copy the code.
Browse the OKLCH color space with sliders for lightness, chroma, and hue. See the CSS oklch() code. Modern and accessible.
Toggle image‑rendering: auto, pixelated, crisp‑edges on a scaled image. Essential for pixel art display.
Upload a gradient or enter a palette and simulate how it appears with different types of color vision deficiency. Ensure inclusive data visualization.
A minimalist countdown timer that overlays on your screen while recording tutorials or demos. Perfect for keeping videos concise without editing.
Choose where page breaks should occur for printing. Get the break‑before, break‑after, and break‑inside CSS.
Create a pure CSS scroll progress indicator using animation‑timeline: scroll(). No JavaScript. Copy the complete code.
Hover over tiles to see every CSS cursor value in action. Quick visual reference for choosing the right UI feedback.
Paste your CSS and see warnings for properties that have limited browser support. Links to CanIUse. Modernize safely.
Query the permission state of camera, microphone, geolocation, and more. See the response and learn the API.
Drop files onto a zone and see a preview with name, size, and type. Copy the JavaScript pattern for your site.
Load any variable font from Google Fonts or local file and play with weight, width, slant, and custom axes. Download CSS.
Test the experimental Translation API to translate text between languages directly in the browser, without cloud calls. Check support and copy the JavaScript starter.
Browse the fonts installed on your system and type a custom phrase to see how it looks. Uses Local Font Access API where available.
See every HTML input type in one page. Check browser support and styling. Copy sample markup. Quick frontend reference.
Apply user‑select: none, text, all and see how it affects selection. Copy the CSS snippet for your UI elements.
Limit browser gestures on an element: pan‑x, pinch‑zoom, manipulation. Draw on a canvas to test. Mobile dev helper.
Toggle scrollbar‑gutter: stable to reserve space for the scrollbar and avoid content jumps. Visual demo with two columns.
Test the Fullscreen API: request fullscreen on a colored div, detect changes, and copy the JavaScript boilerplate.
Style underlines, overlines, and strike-throughs with colors, wavy styles, and thickness. Modern CSS text‑decoration.
Build a 3D rotating cube using pure CSS. Set dimensions, colors, and animation speed. Copy the HTML and CSS.
Design a button or card that glows on hover. Adjust shadow color, spread, and transition. Copy the CSS. Rich UI.
Create a realistic letterpress (debossed) text effect using CSS text‑shadow and background. Adjust depth and light direction. Copy code.
Generate a subtle noise/grain texture as a CSS background pattern. Adjust opacity and size. For that film look.
Create a customizable checkerboard or grid background using pure CSS gradients. Adjust cell size and colors. Copy the code.
Create a pure CSS countdown timer with a flipping number effect. Adjust duration and style. No JavaScript needed for display.
Create a rainbow gradient text animation using pure CSS. Customize speed and colors. Copy the code for your website.
Upload a small image and generate the CSS code for a custom cursor. Test it live on the page. Tiny but useful.
Find safe mixing ratios for the classic elephant toothpaste demonstration. Volume adjustments for different container sizes.