View raw output
Here's a self-contained HTML document that renders a working analog clock with hour, minute, and second hands plus the numbers 1 to 12.
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Analog Clock</title>
<style>
html, body {
height: 100%;
margin: 0;
}
body {
display: grid;
place-items: center;
background: radial-gradient(circle at 50% 22%, #26313f 0%, #0b0f15 70%);
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.clock {
display: block;
width: min(82vmin, 540px);
height: min(82vmin, 540px);
filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.55));
}
.num {
font-family: Georgia, "Times New Roman", serif;
font-size: 15px;
font-weight: 600;
fill: #e6edf7;
}
</style>
</head>
<body>
<svg id="clock" class="clock" viewBox="-100 -100 200 200" role="img" aria-label="Analog clock">
<defs>
<radialGradient id="faceGrad" cx="50%" cy="32%" r="80%">
<stop offset="0%" stop-color="#2f4055"/>
<stop offset="65%" stop-color="#1b2531"/>
<stop offset="100%" stop-color="#101720"/>
</radialGradient>
<linearGradient id="rimGrad" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#93a7bf"/>
<stop offset="45%" stop-color="#3d4c60"/>
<stop offset="100%" stop-color="#161d26"/>
</linearGradient>
<radialGradient id="glass" cx="50%" cy="18%" r="72%">
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.13"/>
<stop offset="60%" stop-color="#ffffff" stop-opacity="0"/>
</radialGradient>
</defs>
<!-- bezel / face -->
<circle r="98" fill="url(#rimGrad)"/>
<circle r="93" fill="#0b1017"/>
<circle r="90" fill="url(#faceGrad)"/>
<!-- generated tick marks and numerals -->
<g id="ticks"></g>
<g id="numbers"></g>
<!-- hands -->
<g id="hourGroup">
<line x1="0" y1="9" x2="0" y2="-46"
stroke="#e6edf7" stroke-width="7" stroke-linecap="round"/>
</g>
<g id="minuteGroup">
<line x1="0" y1="12" x2="0" y2="-62"
stroke="#e6edf7" stroke-width="4.5" stroke-linecap="round"/>
</g>
<g id="secondGroup">
<line x1="0" y1="22" x2="0" y2="-76"
stroke="#ff5a4d" stroke-width="1.6" stroke-linecap="round"/>
<circle cx="0" cy="22" r="3" fill="#ff5a4d"/>
</g>
<!-- centre cap -->
<circle r="5.5" fill="#e6edf7"/>
<circle r="2.4" fill="#ff5a4d"/>
<!-- glass highlight -->
<circle r="90" fill="url(#glass)" pointer-events="none"/>
</svg>
<script>
(function () {
"use strict";
var NS = "http://www.w3.org/2000/svg";
function make(name, attrs) {
var el = document.createElementNS(NS, name);
for (var key in attrs) {
if (Object.prototype.hasOwnProperty.call(attrs, key)) {
el.setAttribute(key, attrs[key]);
}
}
return el;
}
/* ---- build the tick marks ---- */
var ticks = document.getElementById("ticks");
for (var i = 0; i < 60; i++) {
var angle = i * 6;
var isHour = (i % 5 === 0);
ticks.appendChild(make("line", {
x1: 0,
y1: -(isHour ? 78 : 82),
x2: 0,
y2: -88,
stroke: isHour ? "#cfd9e6" : "#6d7f96",
"stroke-width": isHour ? 3.4 : 1.3,
"stroke-linecap": "round",
transform: "rotate(" + angle + ")"
}));
}
/* ---- build the numerals 1..12 ---- */
var numbers = document.getElementById("numbers");
var R = 69;
for (var n = 1; n <= 12; n++) {
var a = n * 30 * Math.PI / 180;
var text = make("text", {
x: (R * Math.sin(a)).toFixed(2),
y: (-R * Math.cos(a)).toFixed(2),
"class": "num",
"text-anchor": "middle",
"dominant-baseline": "central"
});
text.textContent = String(n);
numbers.appendChild(text);
}
/* ---- run the clock ---- */
var hourGroup = document.getElementById("hourGroup");
var minuteGroup = document.getElementById("minuteGroup");
var secondGroup = document.getElementById("secondGroup");
function render() {
var now = new Date();
var ms = now.getMilliseconds();
var sec = now.getSeconds() + ms / 1000;
var min = now.getMinutes() + sec / 60;
var hr = (now.getHours() % 12) + min / 60;
hourGroup.setAttribute("transform", "rotate(" + (hr * 30) + ")");
minuteGroup.setAttribute("transform", "rotate(" + (min * 6) + ")");
secondGroup.setAttribute("transform", "rotate(" + (sec * 6) + ")");
requestAnimationFrame(render);
}
requestAnimationFrame(render);
})();
</script>
</body>
</html>
```
### How the Clock Works
This clock is built with a clean SVG face and a small JavaScript loop that keeps the hands moving.
- **Tick marks and numerals** are generated by the script: 60 tick marks around the dial, with longer, brighter strokes every 5 minutes, plus the numbers 1–12 placed at their correct angles.
- **Hand rotation** uses the current time to calculate each hand's angle. The second hand updates smoothly every frame, while the minute and hour hands advance gradually as seconds pass.
- **Visual feedback** includes a subtle glass highlight, a metallic bezel, and a red second hand so you can read the time at a glance.
---
**Optimization Tip:** You can adjust the hand lengths, colors, and face size by editing the SVG attributes (like `y2` values and `stroke` colors) or the `.clock` width in the CSS.