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.


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.


<html lang="en">
        <div id="mainstopwatch">
            <div class="maintime">
            <span id="mainminute">00</span>
        <span id="mainsecond">00</span>
        <span id="milliseconds">00</span>
    <button id="start" onclick="start();">Start</button>
    <button id="stop" onclick="stop();">Stop</button>
    <button id="stop" onclick="reset();">Reset</button>


                body {
    font-family: arial;
    background: #e0e0e0;
    width: 300px;
    margin: 100px auto;
    padding: 60px 50px 100px;
    text-align: center;
    font-size: 40px;
    border-radius: 38px;
    box-shadow: 6px -6px 8px #9d9d9d,
      -6px 6px 8px #ffffff;

  #mainstopwatch span {
    width: 55px;
    margin: 3px;
    padding: 10px;
    border-radius: 38px;
    display: inline-block;
   box-shadow: 6px -6px 8px #9d9d9d,
      -6px 6px 8px #ffffff;
  #mainstopwatch button {
    border: none;
    -webkit-appearance: none; 
    font-size: 22px;
    width: 140px;
    height: 55px;
    color: white; 
    background-color: #2e80b3;
    border-radius: 33px;
    transition: .3s;
   box-shadow: 6px -6px 8px #9d9d9d,
      -6px 6px 8px #ffffff;
  #mainstopwatch button:nth-of-type(2) {
    background-color: #ae7617;
  #mainstopwatch button:last-child {
      margin-top: 12px;
    background-color: #17ae38;
  #mainstopwatch button:hover {
    background: #333;
    color: #e0e0e0;
    border-radius: 38px;


                var timer = 0;
var timerInterval;
var ms = document.getElementById('milliseconds');
var second = document.getElementById('mainsecond');
var minute = document.getElementById('mainminute');
function start(){
  timerInterval = setInterval( function(){
     timer += 1/60;
    msVal = Math.floor((timer - Math.floor(timer) )*100); // Gives the milliseconds value
     secondVal = Math.floor(timer) - Math.floor(timer/60) *60; // Gives the Second values
    minuteVal = Math.floor(timer/60); // Gives the Minute value
    ms.textContent = msVal <10 ? "0" + msVal.toString() : msVal;
     second.textContent = secondVal < 10 ? "0" + secondVal.toString() : secondVal;
     minute.textContent = minuteVal < 10 ? "0" + minuteVal.toString() : minuteVal;
  }, 1000/60);
function stop(){
function reset(){
    timer = 0;
    ms.textContent = '00';
    second.textContent = '00';
    minute.textContent = '00';