Interview Question

What is prefers-color-scheme?

prefers-color-scheme detects the user’s requested light or dark theme.

💡 Concept ✅ Quick Revision 🎨 CSS

Answer

prefers-color-scheme is a media feature for the user’s light or dark appearance preference. • It commonly provides an alternate color palette. • The color-scheme property can tell controls which schemes the page supports. • A manual user choice should be allowed when the product needs one.

💡 Simple Example

:root { color-scheme: light dark; } @media (prefers-color-scheme: dark) { body { background: #111; color: #eee; } }

⚡ Quick Revision

prefers-color-scheme detects the user’s requested light or dark theme.