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.
Paste the characters your site uses and upload a TTF/OTF font. Download a smaller, subsetted WOFF2 for faster page loads.
Mix realistic rain sounds with optional thunder and wind. Adjust individual volumes to create the perfect sleep or study atmosphere.
Play pure sine, square, sawtooth, or triangle waves at a precise frequency. Can sweep between two frequencies for testing speakers or hearing.
Design a repeating tile pattern by deforming a basic shape. The resulting tessellation fills the plane seamlessly, perfect for backgrounds and fabric design.
Create colorful, bulletproof HTML buttons for email. Uses VML for Outlook, graceful fallback for others.
Upload an image and turn it into a simple digital jigsaw puzzle. Choose number of pieces. Play on screen.
Enter a router's MAC address or serial and generate the common default WPA passphrase for major ISP brands. Educational purpose only.
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.
Pick colors for the shadcn/ui design system and generate the complete CSS variable theme file. Copy into your project.
Create color gradients that are perceptually uniform by interpolating in CIELAB space. Get the CSS linear‑gradient code. Visually superior.
Create a Blob from text or a file and generate a temporary URL for it. Understand the Blob API. Dev demo.
Create a pure HTML dropdown menu using the popover attribute. Style it with CSS and copy the accessible snippet. No JavaScript.
Create custom flat or plastic badges for your GitHub README. Choose label, message, color, and export as Markdown, HTML, or SVG.
Format a list of Q&A pairs and export as a CSV ready for Anki import. Simple line‑based template. Local.
Generate a random medieval occupation with a short description. For NPCs or historical curiosity. Local list.
Design a button or card that glows on hover. Adjust shadow color, spread, and transition. Copy the CSS. Rich UI.
Create a customizable checkerboard or grid background using pure CSS gradients. Adjust cell size and colors. Copy the code.
Enter a message and render it as an image of dots and dashes. Customizable colors. Great for posters.
Convert short text into a black‑and‑white Braille bump image ready for embossing. Educational and inclusive.
Get a humorous, randomly generated daily horoscope for any zodiac sign. Not real astrology; purely for laughs.
Upload a small image and generate the CSS code for a custom cursor. Test it live on the page. Tiny but useful.
Generate a random, somewhat meaningful song lyric line. Write your own hit with AI‑free randomness. All local.
Generate a realistic‑sounding exoplanet designation (e.g., Kepler‑442b) and a sci‑fi planet description. For worldbuilding.
Generate magic squares of odd order (3x3, 5x5, …). See the sum constant and verify rows, columns, diagonals. Educational math toy.
Generate random license keys or serial numbers in various formats (XXXX-XXXX-XXXX). Useful for software activation testing. Local generation.
Convert any image into beautiful ASCII art. Adjust brightness and character set for the best effect. Share text-based pictures. Runs entirely in the browser.