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.


                <svg width="200" height="200" viewBox="-100 -100 200 200">
  <circle class="minute_marker" r="90" pathLength="60" />
  <circle class="hour_marker" r="90" pathLength="60" />
  <text id="text" class="text" x="45" y="5"></text>

  <g id="hour_hand">
    <line class="hand" x1="0" y1="0" x2="0" y2="-50" />
    <line class="hand hand--thick" x1="0" y1="-12" x2="0" y2="-50" />

  <g id="minute_hand">
    <line class="hand" x1="0" y1="0" x2="0" y2="-80" />
    <line class="hand hand--thick" x1="0" y1="-12" x2="0" y2="-80" />

  <g id="second_hand">
    <line class="hand hand--second" x1="0" y1="12" x2="0" y2="-80" />

  <circle class="center" r="3" />

<a id="youtube" target="_blank" href="">
  <span>Learn how to animate SVG from JavaScript</span>
<div id="youtube-card">
  SVG + JavaScript Tutorial: How to animate SVG from JavaScript


                @import url("");

html {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 100%;
  height: 100%;

svg {
  display: none;

body {
  background-color: #7b0828;
  margin: 0;

.hour_marker {
  fill: transparent;
  stroke: #f0f0c9;
  stroke-width: 7;
  stroke-dasharray: 0.2, 4.8;
  stroke-dashoffset: 0.1;

.minute_marker {
  fill: transparent;
  stroke: #0f0e0e;
  stroke-width: 7;
  stroke-dasharray: 0.2, 0.8;
  stroke-dashoffset: 0.1;

.hand {
  stroke: #ffffff;
  stroke-width: 2;
  stroke-linecap: round;

.hand--thick {
  stroke-width: 7;

.hand--second {
  stroke: yellow;

.center {
  fill: #7b0828;
  stroke-width: 2;
  stroke: white;

.text {
  fill: #f0f0c9;
  font-family: "Roboto", sans-serif;
  text-anchor: middle;
  cursor: pointer;
  user-select: none;

#youtube-card {
  display: none;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: black;

@media (min-height: 425px) {
  /** Youtube logo by */
  #youtube {
    z-index: 50;
    width: 100px;
    display: block;
    height: 70px;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: red;
    border-radius: 50% / 11%;
    transform: scale(0.8);
    transition: transform 0.5s;

  #youtube:focus {
    transform: scale(0.9);
    color: black;

  #youtube::before {
    content: "";
    display: block;
    position: absolute;
    top: 7.5%;
    left: -6%;
    width: 112%;
    height: 85%;
    background: red;
    border-radius: 9% / 50%;

  #youtube::after {
    content: "";
    display: block;
    position: absolute;
    top: 20px;
    left: 40px;
    width: 45px;
    height: 30px;
    border: 15px solid transparent;
    box-sizing: border-box;
    border-left: 30px solid white;

  #youtube span {
    font-size: 0;
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;

  #youtube:hover + #youtube-card {
    z-index: 49;
    display: block;
    position: fixed;
    bottom: 12px;
    right: 10px;
    padding: 25px 130px 25px 25px;
    width: 300px;
    background-color: white;




Learn how to code this watch step by step on YouTube:

Follow me on twitter for more:


const textElement = document.getElementById("text");
const hoursElement = document.getElementById("hour_hand");
const minutesElement = document.getElementById("minute_hand");
const secondsElement = document.getElementById("second_hand");

let showDate = true;

function animate() {
  const date = new Date();

  const day = date.getDate();
  const ampm = date.getHours() >= 12 ? "PM" : "AM";
  const hour = date.getHours() + date.getMinutes() / 60;
  const minute = date.getMinutes() + date.getSeconds() / 60;
  const second = date.getSeconds() + date.getMilliseconds() / 1000;

  textElement.textContent = showDate ? day : ampm;
  hoursElement.setAttribute("transform", `rotate(${(360 / 12) * hour})`);
  minutesElement.setAttribute("transform", `rotate(${(360 / 60) * minute})`);
  secondsElement.setAttribute("transform", `rotate(${(360 / 60) * second})`);



textElement.addEventListener("click", () => {
  showDate = !showDate;

document.querySelector("svg").style.display = "block";