Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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.


Auto Save

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.


                <!DOCTYPE html>
<html lang="en">

  <meta charset="UTF-8" />
  <meta name="viewport" content="width=150px, initial-scale=1.0" />
  <title>PJJF Stopwatch</title>
  <link rel="stylesheet" href="style.css" />
  <link href=";900&display=swap" rel="stylesheet" />


  <h1> <img src="" alt="PJJF logo" height="200px"> </h1>

  <div class="stopwatch">
    <h1><span class="gold">PJJF</span> STOPWATCH</h1>
    <div class="circle">
      <span class="time" id="display">00:00:00</span>

    <div class="controls">
      <button class="buttonPlay">
        <img id="playButton" src="" />

        <img id="pauseButton" src="" />

      <button class="buttonReset">
        <img id="resetButton" src="" />
  <script src="script.js"></script>



                body {
  background-color: #2c3347;
  color: #ffffff;

h1 {
  font-size: 48px;
  font-family: "Montserrat", sans-serif;
  font-weight: 1000;
  color: #ff0022;

  text-align: center;
  line-height: 59px;

  padding: 0 64px;
  margin: 0;

.stopwatch {
  display: grid;
  justify-items: center;
  grid-row-gap: 23px;
  width: 100%;
  padding-top: 25px;

.circle {
  display: flex;
  justify-content: center;
  align-items: center;

  height: 400px;
  width: 400px;

  border: 2px solid;
  border-radius: 50%;

.time {
  font-family: "Montserrat", monospace;
  font-weight: 300;
  font-size: 85px;

.gold {
  font-weight: 900;

  color: #00ff55;
  text-shadow: 0 0 0px #fff, 0 0 50px #f2c94c;

.controls {
  display: flex;
  justify-content: space-between;

  width: 187px;

button {
  cursor: pointer;
  background: transparent;
  padding: 0;
  border: none;
  margin: 0;
  outline: none;

#playButton {
  display: block;

#pauseButton {
  display: none;



                // Convert time to a format of hours, minutes, seconds, and milliseconds

function timeToString(time) {
  let diffInHrs = time / 3600000;
  let hh = Math.floor(diffInHrs);

  let diffInMin = (diffInHrs - hh) * 60;
  let mm = Math.floor(diffInMin);

  let diffInSec = (diffInMin - mm) * 60;
  let ss = Math.floor(diffInSec);

  let diffInMs = (diffInSec - ss) * 100;
  let ms = Math.floor(diffInMs);

  let formattedMM = mm.toString().padStart(2, "0");
  let formattedSS = ss.toString().padStart(2, "0");
  let formattedMS = ms.toString().padStart(2, "0");

  return `${formattedMM}:${formattedSS}:${formattedMS}`;

// Declare variables to use in our functions below

let startTime;
let elapsedTime = 0;
let timerInterval;

// Create function to modify innerHTML

function print(txt) {
  document.getElementById("display").innerHTML = txt;

// Create "start", "pause" and "reset" functions

function start() {
  startTime = - elapsedTime;
  timerInterval = setInterval(function printTime() {
    elapsedTime = - startTime;
  }, 10);

function pause() {

function reset() {
  elapsedTime = 0;

// Create function to display buttons

function showButton(buttonKey) {
  const buttonToShow = buttonKey === "PLAY" ? playButton : pauseButton;
  const buttonToHide = buttonKey === "PLAY" ? pauseButton : playButton; = "block"; = "none";
// Create event listeners

let playButton = document.getElementById("playButton");
let pauseButton = document.getElementById("pauseButton");
let resetButton = document.getElementById("resetButton");

playButton.addEventListener("click", start);
pauseButton.addEventListener("click", pause);
resetButton.addEventListener("click", reset);