<div class="option">
  <span class="btn">Dark</span> 
  <span class="btn active">Light</span>  
</div>

<main>
  <header>
    <h1>Exercitation ullamco laboris nisi ut aliquip commodo. 
  </header>
    
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor</p>
  
  <p>in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</main>
* { box-sizing: border-box;}
body {
  margin: 0;
  padding: 15px;
  font: normal normal normal 1rem/1.6 Nunito Sans, Helvetica, Arial, sans-serif;
  color: #222;
  background-color: #e8edec;
}
main {
  width: 100%;
  max-width: 40rem;
  margin: 15px auto;
  padding: 15px;
  background-color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  -moz-box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.option {font-size: 0.8rem;}
.btn {
  padding: 5px 10px;
  background-color: #e8edec;
}
.btn.active {
  background-color: #222;
  color: #fff;
}
.btn:not(.active):hover {cursor: pointer;}

/* Dark Mode */
.dark {
  color: #e8edec;
  background-color: #222;
}
.dark main {
  background-color: #000;
  box-shadow: 0 1px 3px rgba(255,255,255,0.12), 0 1px 2px rgba(255,255,255,0.24);
  -webkit-box-shadow: 0 1px 3px rgba(255,255,255,0.12), 0 1px 2px rgba(255,255,255,0.24);
  -moz-box-shadow: 0 1px 3px rgba(255,255,255,0.12), 0 1px 2px rgba(255,255,255,0.24);
}
.dark .btn {background-color: #222;}
.dark .btn.active {
  background-color: #fff;
  color: #000;
}
$(document).ready(function() {
  const $body = $("body");
  const $btns = $(".btn");
 
  $btns.on("click", function() {
    $btns.removeClass("active");
    $(this).addClass("active");
    $body.toggleClass("dark");
  });
});
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js