Skip to content

Instantly share code, notes, and snippets.

@kekru
Last active January 21, 2024 07:01
Show Gist options
  • Save kekru/3600e9306417bfc28eb16722dd406de0 to your computer and use it in GitHub Desktop.
Save kekru/3600e9306417bfc28eb16722dd406de0 to your computer and use it in GitHub Desktop.
Dark-Mode for simple HTML website

Dark mode for simple HTML website

You can add a very basic dark mode for your website using this CSS snippet:

<!DOCTYPE html>
<html>
<head>
  <style>
    @media (prefers-color-scheme: dark) {
      body {
        background-color: #1B1B1B;
        color: #E7E8EB;
      }
      a {
        color: #3387CC;
      }
    }
  </style>
</head>
<body>
  ...
</body>
</html>

It will apply automatically, when you choose the dark theme in your operating system.
Here is how to do that:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment