prefers‑color‑scheme Live Preview - Online Dark/Light
Toggle between light and dark mode for a demo page. See how to use the media query. Copy the pattern.
UD5 Toolkit
Generate the perfect <meta name="color-scheme"> tag and CSS for dark/light mode opt-in.
Preview, copy, and deploy in seconds.
<head>
color-scheme property together for maximum browser compatibility.
The meta tag signals support early (before CSS loads), while the CSS property provides fine-grained control over specific elements.
<meta name="color-scheme"> tag tells browsers which color schemes (light, dark, or both) your web page supports.
It was introduced to help browsers render native UI elements—like form controls, scrollbars, and auto-filled inputs—in the appropriate theme before your CSS loads.
This prevents the infamous "flash of white" when a dark-mode user visits a dark-themed site.
It's a simple one-line addition to your <head> that significantly improves user experience.
color-scheme is the capability flag, while prefers-color-scheme is the responsive styling tool.
For a complete dark mode implementation, you typically use both.
only keyword (e.g., only light or only dark) forces a specific color scheme and prevents the browser from making automatic adjustments.
For example, only light tells the browser: "This page must always render in light mode, regardless of the user's system preference."
Use this sparingly—only when you have a strong design reason to override user preferences.
Most websites should use light dark to respect user choice and maximize accessibility.
color-scheme meta tag and CSS property are supported in all modern browsers: Chrome 81+, Firefox 96+, Safari 13+ (desktop and iOS), and Edge 81+.
It has excellent cross-browser coverage as of 2024, with over 94% global browser support.
Older browsers simply ignore the tag, so it's safe to add it today without any negative side effects—it's a progressive enhancement.
<meta name="color-scheme"> tag as early as possible inside the <head> section—ideally before any stylesheets or scripts.
This ensures the browser knows about your color scheme support before it starts rendering the page, preventing any flash of incorrect theme.
A good rule of thumb: put it right after the <meta charset="UTF-8"> and <meta name="viewport"> tags.
color-scheme property can be applied to any element, not just :root.
This is useful when you have a component that always looks best in a specific scheme—for example, a code editor widget that should always render in dark mode, or a print preview area that should always be light.
Simply apply color-scheme: dark; or color-scheme: only light; to the specific container element.
<meta name="color-scheme" content="light dark"> tag in your <head>.
(2) Use :root { color-scheme: light dark; } in your CSS.
(3) Write @media (prefers-color-scheme: dark) { } blocks with your dark theme styles.
(4) For a manual toggle, use JavaScript to add a data-theme attribute to <html> and write corresponding CSS selectors.
Store the user's choice in localStorage for persistence across visits.
light dark means "I support both, but prefer light mode as the default."
dark light means "I support both, but prefer dark mode as the default."
The first value is the preferred or default scheme.
Browsers use this information to decide which native UI elements to render when the user hasn't expressed a clear preference.
For most websites, light dark is the safer choice since light mode is the traditional web default.
Copy the generated code above and paste it into your HTML <head> section. All modern browsers are supported.
Toggle between light and dark mode for a demo page. See how to use the media query. Copy the pattern.
Enter hex codes and download a PNG swatch image with color names. Useful for design spec documents. Built via canvas.
Upload a gradient or enter a palette and simulate how it appears with different types of color vision deficiency. Ensure inclusive data visualization.
Upload any picture and instantly get a 5‑color palette. Useful for UI design themes. Canvas‑based extraction.
Start from a base color and use `oklch(from color l c h)` to create lighter or darker variants. Copy the code.
Add a dramatic night‑vision green tint with grain and scanlines to any image. Fun horror/military aesthetic.
A dedicated color picker with common retro gaming palettes (NES, Gameboy). Pick and copy hex codes. For pixel art creators.
Experiment with the CSS color-mix() function. Pick two colors and mix them in different color spaces (srgb, oklch). Copy the CSS.
Convert any image into an 8‑bit indexed PNG by reducing to a custom number of colors. Vintage game look. Local quantizer.
See how your page title and description will look in Google SERP. Check pixel width and character count. Local tool.
Drag and drop light sources, camera, and subject to plan a photo shoot. Export diagram as image. Simple and visual.
Paste a direct link to an image and get its 5 dominant colors with hex codes. No upload, uses canvas with CORS proxy.
Upload an image and extract its dominant colors or full color palette. Download as a CSS snippet or color swatch. Entirely client-side, your images stay private.
Interactively apply CSS filter functions (blur, brightness, contrast, etc.) to an image and copy the resulting filter property. No coding required.
Repeat the growing color sequence. How far can you go? Classic memory game with sound and animations.
Select two paint colors and see approximate mixed result. Visual blending for artists.
Given an RGB value, pick the matching color square. Multiple difficulty levels. Improve your color perception. Fun for designers.
Browse the OKLCH color space with sliders for lightness, chroma, and hue. See the CSS oklch() code. Modern and accessible.
Enter foreground and background colors and see a matrix of how each pair works for normal, protanopia, deuteranopia, and tritanopia.
Generate placeholder images with custom dimensions, background color, and text. Supports SVG and raster output. Perfect for wireframing and mockups.
Enter an image URL and extract its dominant color palette. No download needed. Fast visual analysis.
Enter the URL of any online image and extract its dominant colors or pick colors with a magnifier. No upload, cross‑origin friendly.
Enter the URL of any image and receive a random harmonious palette extracted from it. Click to regen. For quick inspiration.
Convert hex or RGB to CIELAB L*a*b* values. Understand perceptual lightness and color opponents. Local math.
Increase or decrease the color saturation of your photo with a slider. Preview instantly. Download the edited image. Canvas‑based.
Watch and repeat the growing sequence of colored buttons. How long is your memory? Classic electronic game replica.
Upload an image at multiple widths and generate a complete <picture> or <img srcset> snippet. Modern web performance.
Apply a pixel sorting glitch effect to your photo. Sort pixels by brightness, hue, or saturation. Create abstract art. Canvas.
Write a compute shader in WGSL and run it in the browser. See the output on a canvas. Learn WebGPU. Real‑time compilation.
Upload multiple sizes of the same image and generate the complete srcset and sizes attributes. For perfect responsive performance.