Media Query for Dark Mode

Media Query for Dark Mode

Hard CSS Responsive Design 21 views
Explanation Complexity

Problem Statement

Use prefers-color-scheme to adjust colors.

Input Format

No input.

Output Format

Print the HTML+CSS code in one block.

Constraints

Use @media (prefers-color-scheme: dark).

Input / Output Format

Input Format
No input.
Output Format
Print the HTML+CSS code in one block.
Constraints
Use @media (prefers-color-scheme: dark).

Examples

Input:
Output:
(HTML+CSS code)

Example Solution (Public)

CSS
<!doctype html>
<html lang='en'>
<head>
  <meta charset='utf-8'>
  <meta name='viewport' content='width=device-width, initial-scale=1'>
  <title>meetcode</title>
  <style>
    body { margin: 0; font-family: system-ui, Arial, sans-serif; background: #fff; color: #111; padding: 16px; }
    @media (prefers-color-scheme: dark) {
      body { background: #0b1220; color: #f7f7f7; }
    }
  </style>
</head>
<body>
  <h1>meetcode</h1>
  <p>Theme changes with system setting.</p>
</body>
</html>

Official Solution Code

<!doctype html>
<html lang='en'>
<head>
  <meta charset='utf-8'>
  <meta name='viewport' content='width=device-width, initial-scale=1'>
  <title>meetcode</title>
  <style>
    body { margin: 0; font-family: system-ui, Arial, sans-serif; background: #fff; color: #111; padding: 16px; }
    @media (prefers-color-scheme: dark) {
      body { background: #0b1220; color: #f7f7f7; }
    }
  </style>
</head>
<body>
  <h1>meetcode</h1>
  <p>Theme changes with system setting.</p>
</body>
</html>
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.