Will You Be My Valentine Website Template
This is a free Will You Be My Valentine website template: one HTML file with a Yes button and a No button that runs away. Copy the code or download the file, change two names near the top, and host it anywhere that serves a web page. No libraries, no build step, and it works offline.
If you'd rather not touch code at all, our Will You Be My Valentine link maker does the same job in ten seconds and also shows you whether they opened it and what they tapped.
The Will You Be My Valentine HTML code
Everything is in this one file: the card, the styles and the runaway No button. Fonts come from the visitor's own device, so nothing loads from anywhere else.
<!doctype html>
<html lang="en">
<head>
<!-- Edit these two lines, save, and host this file anywhere. -->
<script>
const CARD = { to: "you", from: "someone who likes you" };
</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Will You Be My Valentine? Yes or No Website Template</title>
<meta name="description" content="A free open-source Will You Be My Valentine website: one HTML file, a No button that runs away, nothing to install.">
<style>
:root {
--desk: #2B1721; --desk-deep: #1C0E15; --paper: #FBF4E9; --ink: #2A1A1F;
--muted: #7A6368; --line: #E6D8CC; --rose: #D92D6A; --rose-deep: #B01F53;
--blush: #F8D9E1; --blue: #31598C;
--serif: Georgia, "Times New Roman", serif;
--sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
--hand: "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
min-height: 100vh; min-height: 100dvh; padding: 24px 16px;
display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
background: var(--desk); color: var(--ink); font: 16px/1.6 var(--sans);
}
.card {
container: card / inline-size;
width: min(92vw, 440px); padding: 12px; background: var(--paper); border-radius: 4px;
box-shadow: 0 12px 32px rgba(0,0,0,.35); transform: rotate(-1deg);
}
.card-inner { border: 1px solid var(--rose); padding: 20px 20px 16px; }
.hand { font-family: var(--hand); font-size: 21px; line-height: 1.3; overflow-wrap: anywhere; margin: 0; }
.from { text-align: right; }
h1 { font: 400 32px/1.15 var(--serif); margin: 16px 0; }
.stub { position: relative; margin: 16px -20px 0; padding: 0 20px; border-top: 2px dashed var(--line); }
/* Reply stub: 10 + 68 + 8 + 88 + 10 = 184px stacked; 12 + 96 + 12 = 120px side by side. */
.zones { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; }
.yes-zone { height: 68px; display: flex; align-items: center; justify-content: center; }
.no-zone { position: relative; height: 88px; }
/* Side by side once the card is at least 400px wide on the outside (376px inside its 12px padding). */
@container card (min-width: 376px) {
.zones { flex-direction: row; gap: 0; padding: 12px 0; }
.yes-zone { width: 45%; height: 96px; }
.no-zone { width: 55%; height: 96px; }
}
button { font: 600 16px/1 var(--sans); cursor: pointer; }
.yes {
width: 120px; height: 48px; border: 0; border-radius: 12px; background: var(--rose); color: #fff;
transition: transform .16s ease-out;
}
.yes:hover { background: var(--rose-deep); }
.no {
position: absolute; left: 0; top: 0; height: 44px; min-width: 88px; max-width: 140px; padding: 0 10px;
border: 1.5px solid var(--ink); border-radius: 12px; background: transparent; color: var(--ink);
white-space: nowrap;
transition: left .18s ease-out, top .18s ease-out;
}
button:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.kind { display: block; margin: 12px auto 0; padding: 4px; border: 0; background: none; color: var(--blue); font: 400 14px/1.5 var(--sans); text-decoration: underline; }
.kind.off { visibility: hidden; }
.stamp {
position: absolute; left: 50%; top: 50%; width: 104px; height: 104px; margin: -46px 0 0 -52px;
display: grid; place-items: center; border: 3px double var(--rose); border-radius: 50%; color: var(--rose);
font: 400 30px/1 var(--serif); transform: rotate(-8deg); opacity: 0; transition: opacity .4s ease-out; pointer-events: none;
}
.answered .stamp { opacity: .92; }
.answered .zones { visibility: hidden; }
.not-now { display: none; font-family: var(--hand); font-size: 26px; text-align: center; margin: 24px 0; }
.declined .zones, .declined .kind { display: none; }
.declined .not-now { display: block; }
.after { min-height: 24px; margin: 0; color: var(--blush); text-align: center; }
.note { width: min(92vw, 440px); margin: 0; padding: 12px 16px; border-radius: 12px; background: var(--paper); font-size: 14px; line-height: 1.5; }
.note a { color: var(--blue); }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { .yes, .no, .stamp { transition: opacity .12s linear; } }
</style>
</head>
<body>
<main class="card" id="card">
<div class="card-inner">
<p class="hand" id="to"></p>
<h1>Will you be my Valentine?</h1>
<p class="hand from" id="from"></p>
<div class="stub" id="stub">
<div class="zones">
<div class="yes-zone"><button class="yes" id="yes" type="button">Yes</button></div>
<div class="no-zone" id="noZone"><button class="no" id="no" type="button">No</button></div>
</div>
<div class="stamp" aria-hidden="true">YES</div>
<p class="not-now" id="notNow">Not this time.</p>
<button class="kind off" id="kind" type="button" tabindex="-1" aria-hidden="true">Not this time</button>
</div>
</div>
</main>
<p class="after" id="after" role="status"></p>
<p class="note">This is a free template. Want their name on it without touching code, and a page that shows their answer? Use <a href="https://valentineyesorno.com/?s=gh">valentineyesorno.com</a></p>
<script>
(function () {
var LABELS = ["No", "Are you sure?", "Really sure?", "Think again?", "Last chance"];
var KIND_NO_AFTER = 3, MOUSE_DODGES = 6, NEAR = 56, AWAY = 72, YES_W = 120, YES_H = 48;
var $ = function (id) { return document.getElementById(id); };
var yes = $("yes"), no = $("no"), zone = $("noZone"), stub = $("stub"), kind = $("kind"), after = $("after");
var taps = 0, dodges = 0, spot = -1, done = false;
var calm = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
$("to").textContent = "Dear " + CARD.to + ",";
$("from").textContent = "— " + CARD.from;
document.title = "A question for " + CARD.to;
function spots() {
var w = zone.clientWidth, h = zone.clientHeight, bw = no.offsetWidth, bh = no.offsetHeight, out = [];
for (var r = 0; r < 2; r++) for (var c = 0; c < 3; c++) {
var x = Math.round((w - bw) * c / 2), y = Math.round((h - bh) * r);
if (x >= 0 && y >= 0 && x + bw <= w && y + bh <= h) out.push({ i: r * 3 + c, x: x, y: y });
}
return out;
}
function place(p) { spot = p.i; no.style.left = p.x + "px"; no.style.top = p.y + "px"; }
function hop(px, py) {
if (calm) return;
var zr = zone.getBoundingClientRect(), bw = no.offsetWidth, bh = no.offsetHeight;
var list = spots().filter(function (p) { return p.i !== spot; });
if (!list.length) return;
var far = function (p) { return Math.hypot(zr.left + p.x + bw / 2 - px, zr.top + p.y + bh / 2 - py); };
var ok = list.filter(function (p) { return far(p) >= AWAY; });
var pick = ok.length ? ok[Math.floor(Math.random() * ok.length)] : list.sort(function (a, b) { return far(b) - far(a); })[0];
place(pick);
}
function offerKindNo() {
if (done || !kind.classList.contains("off")) return;
kind.classList.remove("off"); kind.removeAttribute("tabindex"); kind.removeAttribute("aria-hidden");
}
function grow() {
// Tier cap 1.25 stacked / 1.4 side by side (45/55 zones), and never closer than 4px to the Yes zone edges.
var yz = yes.parentNode, wide = zone.offsetTop === yz.offsetTop;
var cap = Math.min(wide ? 1.4 : 1.25, (yz.clientWidth - 8) / YES_W, (yz.clientHeight - 8) / YES_H);
yes.style.transform = "scale(" + Math.min(cap, Math.pow(1.08, taps)).toFixed(3) + ")";
}
no.addEventListener("click", function (e) {
if (done) return;
taps = Math.min(99, taps + 1);
no.textContent = LABELS[Math.min(taps, LABELS.length - 1)];
grow();
var r = no.getBoundingClientRect();
hop(e.clientX || r.left + r.width / 2, e.clientY || r.top + r.height / 2);
if (taps >= KIND_NO_AFTER) offerKindNo();
});
document.addEventListener("pointermove", function (e) {
if (done || calm || e.pointerType !== "mouse") return;
var r = no.getBoundingClientRect();
var dx = Math.max(r.left - e.clientX, 0, e.clientX - r.right), dy = Math.max(r.top - e.clientY, 0, e.clientY - r.bottom);
if (Math.hypot(dx, dy) < NEAR) {
var before = spot;
hop(e.clientX, e.clientY);
if (spot !== before && ++dodges >= MOUSE_DODGES) offerKindNo();
}
});
yes.addEventListener("click", function () {
if (done) return;
done = true;
stub.classList.add("answered");
kind.classList.add("off");
after.textContent = "It's a date. Go tell them in person.";
});
kind.addEventListener("click", function () {
if (done) return;
done = true;
stub.classList.add("declined");
after.textContent = "An honest answer. Thanks for giving one.";
});
var first = spots()[0];
if (first) place(first);
window.addEventListener("resize", function () { var p = spots().filter(function (q) { return q.i === spot; })[0] || spots()[0]; if (p) place(p); });
})();
</script>
</body>
</html>
<!-- MIT License. Copyright (c) 2026 Valentine Yes or No -->
How to make a Will You Be My Valentine website in three steps
- Get the file. Press Download .html, or press Copy code and paste it into a new file in any text editor (Notepad, TextEdit in plain text mode, VS Code). Save it as
index.html. - Change the two names. Near the top you'll see
const CARD = { to: "you", from: "someone who likes you" };. Replaceyouwith their name andsomeone who likes youwith yours. Keep the quote marks. - Test it. Double-click the file to open it in your browser. Try the No button with your mouse, then open the file on your phone and tap it.
That's the whole edit. Everything else is optional.
Three free ways to host your Valentine website
Once the file works on your computer, you need a public link to send. All three of these have free plans. Menu names on these services change from time to time, so look for the closest match.
GitHub Pages
Create a free GitHub account and a new public repository. Upload your index.html, then open the repository's Settings, go to Pages, choose to deploy from a branch, and pick your main branch and the root folder. After a minute or two your page is live at an address like your-name.github.io/repository-name. This is the most common way people host a Valentine website from GitHub.
Netlify Drop
Put index.html in a folder on its own and drag the folder onto Netlify's Drop page. You get a random web address within seconds. Netlify may ask you to create a free account to keep the site online, so do that before you send the link.
Cloudflare Pages
In a free Cloudflare account, create a new Pages project and choose to upload your files directly instead of connecting a repository. Drag in the folder with index.html, pick a project name, and your site goes live at project-name.pages.dev.
Whichever you pick, open the final link on your own phone before you send it.
How does the runaway No button work?
The code behind a Will You Be My Valentine website is mostly about the No button. Here's what this template does, so you can change it with confidence:
- The reply area has two zones. Yes sits in its own zone and No moves only inside the other one, so the two buttons can never overlap. On narrow screens the zones stack; on wider cards they sit side by side.
- No picks from six spots. The script lays out a grid of three columns and two rows inside the No zone and skips any spot that doesn't fit. It moves to a spot at least 72 pixels from the pointer, or to the farthest one if none is that far.
- Taps and dodges are counted separately. A real click, tap, or Enter on No counts as a tap, changes its label (No, Are you sure?, Really sure?, Think again?, Last chance) and makes Yes 8% bigger. A mouse coming close only makes it dodge.
- There's always a way out. After three taps on No, or six dodges with a mouse, a "Not this time" button appears. Pressing it writes "Not this time." on the card instead of a stamp.
- Yes gets a stamp. Tapping Yes fades in a round YES stamp over the reply area.
- Reduced motion is respected. If the visitor's device asks for less motion, No stays put and only its label changes.
The numbers live at the top of the script (KIND_NO_AFTER, MOUSE_DODGES, NEAR, AWAY) if you want to tune them.
What this template can't do
It can't put a name on the card without editing the file, and it can't tell you whether they opened it or what they answered. It's a static page: nothing is saved anywhere.
If you want those two things without code, use the free Valentine link maker on our homepage. You type their name, send the link, and keep an owner link that shows whether the card was opened, whether they tapped Yes, or whether they chose a kind "not this time".
Template or link maker: which should you use?
- Use the template if you like building things, want to host it on your own GitHub or domain, or want to change the design.
- Use the link maker if you want it done in a few seconds, want their name on the card without editing a file, or want to see the answer.
Either way, the question is the same. For the words around it, see our Will You Be My Valentine messages, and if you're still working up the nerve, how to ask someone to be your Valentine.
Will You Be My Valentine website template: quick answers
Is this Will You Be My Valentine template free?
Yes. It's free to use, change and share, including on your own site. The code is released under the MIT license, noted at the bottom of the file.
Do I need to know how to code?
No. You only change two names between quote marks near the top of the file. If you can edit a text message, you can edit this.
Does the template work on phones?
Yes. On a phone, each tap on No counts and then the button hops to a new spot inside the card. After three taps a "Not this time" button appears.
Can I see if they clicked Yes or No?
Not with the template. It's a single static file with no server behind it, so nothing is recorded. If you want to see whether the card was opened and what was tapped, use the free link maker on our homepage.
Can I add a photo, GIF or music?
You can add an image tag yourself, but the template deliberately stays one file with nothing to load. Every extra file is something else that can break when you host it, so keep additions small and test the page on your phone.
Ask with a link, and see their answer.
Make my link