How to Make a Register Page Using CSS and HTML

How to Make a Register Page Using CSS and HTML

  • #html
  • #css
  • #forms
  • #tutorial

Building a Register Page with HTML & CSS

A registration page is one of the most common things you’ll build. Let’s create one that’s semantic, accessible, and responsive — no frameworks required.

The HTML structure

Start with semantic elements. Use <form>, <fieldset>, and <label> properly — they give you accessibility for free.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Register</title>
    <link rel="stylesheet" href="styles.css" />
  </head>
  <body>
    <main class="register-page">
      <form class="register-form" novalidate>
        <h1>Create your account</h1>

        <fieldset>
          <legend>Account details</legend>

          <div class="field">
            <label for="name">Full name</label>
            <input type="text" id="name" name="name" autocomplete="name" required />
          </div>

          <div class="field">
            <label for="email">Email</label>
            <input type="email" id="email" name="email" autocomplete="email" required />
          </div>

          <div class="field">
            <label for="password">Password</label>
            <input type="password" id="password" name="password" autocomplete="new-password" required minlength="8" />
          </div>

          <div class="field">
            <label for="confirm">Confirm password</label>
            <input type="password" id="confirm" name="confirm" autocomplete="new-password" required />
          </div>
        </fieldset>

        <button type="submit">Register</button>

        <p class="signin-link">
          Already have an account? <a href="/login">Sign in</a>
        </p>
      </form>
    </main>
  </body>
</html>

The CSS

Now let’s style it. We’ll use CSS custom properties, fluid typography with clamp(), and a centered card layout.

:root {
  --bg: #0f0f10;
  --card: #161618;
  --text: #e8e8e8;
  --muted: #9a9a9a;
  --border: #2a2a2e;
  --accent: #a78bfa;
  --radius: 0.6rem;
}

* {
  box-sizing: border-box;
  margin: 0;
}

body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.register-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.register-form {
  width: 100%;
  max-width: 26rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.register-form h1 {
  font-size: clamp(1.4rem, 2vw + 1rem, 1.8rem);
  margin-bottom: 1.25rem;
  text-align: center;
}

fieldset {
  border: none;
  padding: 0;
  margin-bottom: 1.25rem;
}

.field {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

button {
  width: 100%;
  padding: 0.8rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  opacity: 0.9;
}

.signin-link {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.signin-link a {
  color: var(--accent);
}

Key takeaways

  • display: grid; place-items: center; — the easiest way to center a card both horizontally and vertically, no flexbox hacks needed.
  • clamp() for the heading — the font scales fluidly between min and max based on viewport width. No media queries.
  • autocomplete attributes — tell the browser what kind of data to pre-fill, improving UX and security.
  • novalidate on the form — lets you handle validation in JS if you want custom messaging, while native attributes like required and minlength still guide the browser autofill.

That’s a complete, production-ready register page in under 100 lines of CSS.

← Back to all posts