Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


    <meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" href="main.css" />
    <div id="main" class="page active">
      Alle og en hver ser ut til å ha en formening om bompenger i disse dager.
      Jeg har skal ikke stille meg på en side i denne saken, men tenker jeg kan
      bidra i saken med å samle informasjon om de bumpengene vi har i Norge i
      dag og dere takster.
      <br />
      <br />
      <a href="#toll" class="click-me">Oversikt over bompenger med takster</a>
      <br />
      <br />
      <a href="#denne-siden-finnes-ikke" class="click-me">404</a>
    <div id="toll" class="page">
      <a href="#main">&lt; Tilbake til forsiden</a>
      <div id="tollStations"></div>
    <div id="page404" class="page">
      <h2 id="page404-error"></h2>
    <script src="main.js"></script>


                body {
  background: #eee;
  max-width: 800px;
  margin: 0 auto;
  padding: 10px;

.page {
  display: none;
} {
  display: block;

.click-me {
  display: inline-block;
  padding: 10px;
  border-radius: 10px;
  background: orange;
  color: black;
  text-decoration: none;
  box-shadow: 5px 5px grey;

  margin: 0 0 3px 0;

.click-me:hover {
  margin: 3px 0 0 3px;
  box-shadow: 2px 2px grey;

.toll {
  border: 1px solid grey;
  box-shadow: 5px 5px grey;
  border-radius: 10px;
  margin: 50px 30px;
  padding: 10px;

.toll:hover {
  transition-duration: 0.5s;
  transform: scale(1.1);


                // Define html element references
PAGES = {};

// Main page
PAGES.main = {}; = document.querySelector("#main");

// Some other page
PAGES.toll = {}; = document.querySelector("#toll");
PAGES.toll.content = document.querySelector("#tollStations");

// 404
PAGES.page404 = {}; = document.querySelector("#page404");
PAGES.page404.error = document.querySelector("#page404-error");

// Code to run for each page
pageFunctions = {};

// Custom code to run when showing the 404 page
pageFunctions.page404 = function() {
  PAGES.page404.error.innerHTML = `Page ${location.hash.substr(1)} not found!`;

pageFunctions.toll = function() {
    .then(response => response.json())
    .then(json => {
      PAGES.toll.content.innerHTML = json.entries.reduce((acc, toll) => {
        return (acc += tollInfo(toll));
      }, "");

function tollInfo(toll) {
  return `
  <div class="toll">
  <h3>Takst stor bil: ${toll.takst_stor_bil}</h3>
  <h3>Takst liten bil: ${toll.takst_liten_bil}</h3>

var path;

// Navigation
function navigate() {
  // Get the url path in a easy
  path = location.hash

  // Find what page to show
  var currentPage = path[0];
  if (!PAGES.hasOwnProperty(currentPage)) {
    if (path[0] === "") {
      currentPage = "main";
    } else {
      currentPage = "page404";

  // Hide the previous active page
  for (var page in PAGES) {
    if (PAGES.hasOwnProperty(page)) {

  // Show the active page and run its custom script

  //Run custom page code if it exists
  if (pageFunctions.hasOwnProperty(currentPage)) {

// First time loading the page

window.onhashchange = navigate;