← Demos
Web Pages · Hello World

Hello NASCAR

Build a single html page that says hello world with a nascar race track going around it, with cars going randomized speeds, with a button that restarts the race.

by Cruse Hedden Aug 31, 2026 12 views 6.1 KB
Sandbox · hello-nascar · no access to your account
View source — the whole page is this one file
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello World Raceway</title>
<style>
  :root{--ink:#f8fbff;--muted:#a8b7c9;--bg:#08111e;--panel:#101d2d;--red:#ff4d5d}
  *{box-sizing:border-box}
  body{margin:0;min-height:100vh;background:radial-gradient(circle at 50% 42%,#193450 0,#0b1828 48%,#050b13 100%);color:var(--ink);font-family:system-ui,-apple-system,Segoe UI,sans-serif;display:grid;place-items:center;overflow:hidden}
  main{width:min(1120px,100vw);padding:20px;text-align:center}
  header{display:flex;justify-content:space-between;align-items:center;gap:16px;margin:0 auto 8px;max-width:1000px}
  .eyebrow{color:#ffbd4a;font-size:.72rem;letter-spacing:.2em;text-transform:uppercase;font-weight:800}
  h1{font-size:clamp(1.4rem,3vw,2.2rem);margin:.1rem 0;font-weight:850;letter-spacing:-.04em}
  button{border:0;border-radius:999px;background:var(--red);color:white;padding:12px 19px;font-weight:800;cursor:pointer;box-shadow:0 5px 0 #a82738;transition:.15s transform,.15s box-shadow}
  button:hover{transform:translateY(-2px);box-shadow:0 7px 0 #a82738}
  button:active{transform:translateY(3px);box-shadow:0 2px 0 #a82738}
  button:focus-visible{outline:3px solid #ffcf64;outline-offset:4px}
  .stage{position:relative;max-width:1000px;margin:auto;border:1px solid #30445c;border-radius:24px;background:#0c1725;box-shadow:0 24px 70px #0008;overflow:hidden}
  svg{display:block;width:100%;height:auto}
  .crowd{fill:#8da0b8;animation:cheer .65s ease-in-out infinite alternate}
  @keyframes cheer{to{transform:translateY(-3px);fill:#e5edf5}}
  .lane{fill:none;stroke:#8993a0;stroke-width:2;stroke-dasharray:10 12;opacity:.65}
  .lane.edge{stroke:#d5dbe0;stroke-width:4;stroke-dasharray:none}
  .car{filter:drop-shadow(0 3px 2px #0009)}
  .car rect{stroke:#fff8;stroke-width:1}
  .windshield{fill:#b9e9ef!important;stroke:#193444!important}
  .infield{fill:#145333;stroke:#53a66b;stroke-width:4}
  .status{position:absolute;bottom:10px;left:0;right:0;color:#b9c7d6;font-size:.76rem;letter-spacing:.08em}
  .check{fill:#fff}.dark{fill:#101820}
  @media(max-width:600px){main{padding:10px 8px}header{align-items:flex-start}.eyebrow{font-size:.6rem}button{padding:10px 13px;font-size:.8rem}.stage{border-radius:17px}.status{font-size:.62rem}}
</style>
</head>
<body>
<main>
  <header>
    <div style="text-align:left"><div class="eyebrow">Welcome to the</div><h1>Hello World Raceway</h1></div>
    <button id="restart" type="button">↻ Restart race</button>
  </header>
  <section class="stage" aria-label="Animated six-lane NASCAR-style race track">
    <svg id="track" viewBox="0 0 1000 700" role="img" aria-labelledby="title desc">
      <title id="title">Six cars racing around Hello World</title>
      <desc id="desc">A cheering dotted crowd surrounds an oval race track. Six colorful cars move at different speeds.</desc>
      <rect width="1000" height="700" fill="#0c1725"/>
      <g id="crowd"></g>
      <ellipse cx="500" cy="350" rx="425" ry="300" fill="#182839" stroke="#344961" stroke-width="10"/>
      <ellipse cx="500" cy="350" rx="400" ry="275" fill="#303841" stroke="#d7dde2" stroke-width="7"/>
      <ellipse class="infield" cx="500" cy="350" rx="278" ry="174"/>
      <g id="lanes"></g>
      <g opacity=".9">
        <path d="M245 350h-43m553 0h43" stroke="#f5f7fa" stroke-width="5"/>
        <path class="check" d="M202 336h18v9h-18zm18 9h18v9h-18zm-18 9h18v9h-18zM780 336h18v9h-18zm-18 9h18v9h-18zm18 9h18v9h-18z"/>
        <path d="M420 240h160" stroke="#81d693" stroke-width="3" stroke-dasharray="7 8"/>
        <text x="500" y="326" text-anchor="middle" fill="#d9ffe0" font-size="54" font-weight="900" letter-spacing="-3">HELLO</text>
        <text x="500" y="382" text-anchor="middle" fill="#fff" font-size="67" font-weight="900" letter-spacing="-5">WORLD</text>
        <text x="500" y="416" text-anchor="middle" fill="#9bd7a7" font-size="13" font-weight="700" letter-spacing="5">START YOUR ENGINES</text>
      </g>
      <g id="cars"></g>
    </svg>
    <div class="status" aria-live="polite">SIX LANES • RANDOMIZED SPEEDS • CHEER LOUD</div>
  </section>
</main>
<script>
const svg=document.getElementById('track'), crowd=document.getElementById('crowd'), lanes=document.getElementById('lanes'), cars=document.getElementById('cars');
const NS='http://www.w3.org/2000/svg', cx=500, cy=350;
const colors=['#ff4d5d','#ffbd36','#4fc3ff','#b875ff','#55d68a','#ff7b35'];
let racers=[], running=true, last=performance.now();

function el(tag,attrs,parent){let e=document.createElementNS(NS,tag);for(let k in attrs)e.setAttribute(k,attrs[k]);parent.appendChild(e);return e}
for(let i=0;i<145;i++){
  let side=i%4,x,y;
  if(side<2){x=95+Math.random()*810;y=side?625+Math.random()*25:62+Math.random()*25}
  else{x=side===2?65+Math.random()*25:910+Math.random()*25;y=125+Math.random()*450}
  let d=el('circle',{cx:x,cy:y,r:Math.random()*2.7+1.5,class:'crowd'},crowd);
  d.style.animationDelay=(Math.random()*-.8)+'s';
}
const radii=[294,312,330,348,366,384];
radii.forEach((r,i)=>el('ellipse',{cx,cy,rx:r,ry:r*.69,class:'lane '+(i===0||i===5?'edge':'')},lanes));
function makeCar(i){
  let g=el('g',{class:'car'},cars);
  el('rect',{x:-18,y:-8,width:36,height:16,rx:6,fill:colors[i]},g);
  el('rect',{x:-5,y:-6,width:11,height:12,rx:3,class:'windshield'},g);
  el('rect',{x:8,y:-5,width:6,height:10,rx:2,fill:'#18212c'},g);
  el('circle',{cx:-11,cy:-9,r:3,fill:'#101820'},g);el('circle',{cx:11,cy:9,r:3,fill:'#101820'},g);
  return {g,r:radii[i],a:Math.random()*Math.PI*2,s:.00042+Math.random()*.00034};
}
function reset(){racers.forEach((r,i)=>{r.a=Math.random()*6.28;r.s=.00042+Math.random()*.00034});running=true}
for(let i=0;i<6;i++)racers.push(makeCar(i));
document.getElementById('restart').onclick=reset;
function animate(now){
  let dt=Math.min(now-last,40);last=now;
  if(running)racers.forEach(r=>{
    r.a+=r.s*dt;
    let ry=r.r*.69,x=cx+r.r*Math.cos(r.a),y=cy+ry*Math.sin(r.a);
    let angle=Math.atan2(ry*Math.cos(r.a),-r.r*Math.sin(r.a))*180/Math.PI;
    r.g.setAttribute('transform',`translate(${x} ${y}) rotate(${angle})`);
  });
  requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</body>
</html>

Reaches out to

Websites this page contacts when it runs — fonts, chart libraries, data. Found by reading its source.

  • www.w3.org

Licence

Published on Globefin under the MIT License. You may copy, change, and reuse this page, including commercially — just keep the notice below with it.

Copyright © 2026 Cruse Hedden. Licensed under the MIT License. Published on Globefin.

Provided as is, without warranty. Any external libraries it loads keep their own licences. Terms →

Sandbox

Scripts run, but the demo has its own throwaway origin. It can't read your session or cookies, can't reach the page around it, and can't navigate your tab. Don't enter real passwords or personal data into any demo.