The prefers-color-schemeCSS 5 Media Query is used to detect if the user has requested the system use a light or dark color theme. This Pen demonstrates how to use a theme toggle for both legacy and progressice code. Check Caniusefor support.