Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

how to make a dark mode html

<!DOCTYPE html>
<html>
    <head><title>How to Dark Mode in HTML5</title></head>
    <body>
        <button onclick="darkMode()">Click me</button>
    </body>
    <script>
        function darkMode() {
            if (document.body.style.backgroundColor == "black") {
                document.body.style.backgroundColor = "white";
            } else {
                document.body.style.backgroundColor = "black";
            }
            console.log(document.body.style.backgroundColor);   // ctrl + j and you can see which mode you're in
        }
    </script>
</html>
 
PREVIOUS NEXT
Tagged: #dark #mode #html
ADD COMMENT
Topic
Name
3+6 =