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.
Enter a router's MAC address or serial and generate the common default WPA passphrase for major ISP brands. Educational purpose only.
Pick colors for the shadcn/ui design system and generate the complete CSS variable theme file. Copy into your project.
Format a list of Q&A pairs and export as a CSV ready for Anki import. Simple line‑based template. Local.
Style underlines, overlines, and strike-throughs with colors, wavy styles, and thickness. Modern CSS text‑decoration.
Generate a random medieval occupation with a short description. For NPCs or historical curiosity. Local list.
Generate a hardboiled film noir plot with a detective, a dame, and a McGuffin. Great for creative writing prompts.
Generate a grand, aristocratic title like 'Duke of Waffleshire'. Perfect for silly fun or RPG characters. Local.
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 realistic‑sounding dinosaur name and see a fun description. Perfect for kids and writers.
Generate random but realistic‑looking data arrays (users, products, orders) with typos and missing fields. For test robustness.
Create a customizable checkerboard or grid background using pure CSS gradients. Adjust cell size and colors. Copy the code.
Create a QR code that lets people connect to your Wi‑Fi without typing a password. Just scan and join. Secure local.
Create a custom HTML/CSS progress bar with percentage, colors, and animation. Copy the code. Modern UI element.
Fill in a few details and get a polished resignation letter. No data stored. Instant copy or print.
Paste plain text and turn it into a nested outline using indent levels or Markdown headings. Great for planning.
Upload a small pixel art image and get a CSS grid layout that recreates it using divs. Novelty developer tool.
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.
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.
Create a realistic‑looking fake tweet with any name, handle, text, likes, and retweets. Just for laughs. All local canvas.
Click for an endless stream of random dad jokes and puns. Copy and share. Guaranteed to make you groan. All local.
Generate magic squares of odd order (3x3, 5x5, …). See the sum constant and verify rows, columns, diagonals. Educational math toy.
Enter a list of words and create a custom word search grid. Choose difficulty, print or export as PDF. Great for teachers.
One click to get a hilarious excuse for being late, missing homework, or not doing chores. Pure comedy.
Design a realistic-looking fake receipt with custom store name, items, and total. For jokes and gags. No real transaction.