To design a quiz web page in HTML, start with semantic markup for each question, then wire up scoring and feedback with CSS and JavaScript. The core condition is that you have a plain text editor, a modern browser, and a folder for three files: one HTML page, one CSS file, and one JavaScript file. The markup alone can display questions, but a usable quiz needs logic to check answers, prevent double-scoring, and show a result. This guide builds a self-contained multiple-choice quiz—roughly 40 questions' worth of capacity—without frameworks, then explains how to extend it safely. Everything below uses stable web-platform features available in current browsers as of late 2026.
What "Designing a Quiz Page" Actually Requires
A quiz page is three layers stacked on one document. HTML supplies structure: the question text, the answer choices, and the controls. CSS supplies presentation: spacing, readable type, clear selected and correct states. JavaScript supplies behavior: reading the user's choice, comparing it to the answer key, tallying points, and swapping the visible panel when the quiz ends.
Skipping the first layer is the most common beginner mistake. A quiz built entirely from JavaScript-generated markup works, but it is harder to read, harder to style consistently, and invisible to assistive technology if you are careless. Write the questions in HTML, keep the answers in a JavaScript data structure, and let each layer do its own job.
Decide your quiz shape before writing code. The choices that matter are single-choice versus multiple-answer, instant feedback versus feedback at the end, one question per screen versus all questions on one scrolling page, and whether answers are weighted. Each choice changes the markup and the logic. This walkthrough uses single-choice questions with immediate feedback and a final score, the most common classroom and training pattern.
Prerequisites and File Setup
You need a text editor (any will do), a browser for testing, and three files in the same folder so relative paths resolve. Create:
index.html — the page and question markup styles.css — visual design quiz.js — scoring and interaction
Open index.html directly in a browser during development. No server is required for this version because it does not fetch external data. That changes later if you move questions into a separate JSON file, since browsers block file-based fetches for security; the section on scaling explains the workaround.
Step 1: Write the Semantic Question Markup
Semantic HTML means using elements for what they are, not what they look like. A question is arguably a fieldset with a legend describing the prompt, and each answer is a labeled radio button. Radios sharing a name attribute form a group where only one can be selected—exactly the behavior a single-choice quiz needs.
Here is the skeleton for one question:
Three details carry the design. The name="q1" ties the radios together. The value attributes give each choice a stable identifier the script can compare. The data-answer attribute stores the correct value on the fieldset, keeping the key next to the question it belongs to. Escaping angle brackets as < and > is mandatory; raw tags inside text would be parsed as markup and vanish.
Repeat this block for every question, incrementing the name (q2, q3, and so on). For a ten-question quiz, that is ten fieldsets. It is verbose, and that is fine—the verbosity is what makes the page inspectable and styleable.
Step 2: Add the Controls and Result Region
Below the questions, add a submit button and an element to hold the score. Wrap everything in a form so the button has natural semantics and keyboard users get expected behavior:
The novalidate attribute suppresses browser validation bubbles, which would otherwise appear because radio groups are technically required only if you mark them so. The role="status" and aria-live="polite" pair tells screen readers to announce the result paragraph when its text changes—an accessibility detail that costs one attribute and is frequently forgotten.
If you prefer feedback after each question rather than at submission, place a small empty paragraph inside each fieldset and have the script fill it. Both patterns are valid; this build uses the submit-at-the-end pattern because it produces one clear score.
Step 3: Style the Page With CSS
Styling sets the quiz's usability more than its beauty. Three priorities: readable line length, obvious selection state, and distinguishable correct/incorrect markers that do not rely on color alone.
A max-width near 42rem keeps lines in a comfortable reading range. Making labels block-level and clickable enlarges the hit target—users can click the text, not just the tiny radio circle. The ::after glyphs add a shape cue so colorblind users are not dependent on hue alone; pair them with text in the feedback message for full clarity (WCAG's use-of-color guidance treats color as insufficient on its own).
Do not hide the radio inputs with display: none. They remain keyboard-focusable and screen-reader-announced as visible elements. If you want custom-looking controls, style an adjacent span and leave the input visually available or use a properly labeled pattern—but for a first build, the native control is the accessible choice.
Step 4: Score the Quiz With JavaScript
The script has one job per step: intercept submission, read each group, compare to the key, count, and render. Here is a complete working version:
Walk through the logic. preventDefault stops the browser from navigating away on submit, which would discard the state. querySelectorAll gathers every question fieldset. Inside the loop, input:checked finds the selected radio—or null if the user skipped the question. Comparing chosen.value to fieldset.dataset.answer implements the key. Clearing both state classes first makes re-submission idempotent: a user who changes an answer and resubmits gets a fresh score rather than accumulated styling.
The elapsed time is measured in milliseconds for all practical purposes; this loop over forty questions finishes before the browser paints, so no loading state is needed.
Step 5: Test and Verify Success
Testing a quiz is about confirming four behaviors, not admiring the layout. Load index.html and check:
1: Selecting a second answer in the same question deselects the first. If it does not, your radio names differ. 2: Submitting with all correct answers reports the full count. If it reports zero, the value attributes and data-answer values disagree—compare them character by character. 3: Submitting with one wrong answer marks exactly that fieldset incorrect. If multiple fieldsets react, your names or keys are misaligned. 4: Submitting twice with an answer changed updates the score rather than doubling it. If the total exceeds the question count, remove the class-clearing line and see the difference—that line exists to prevent stale state.
A keyboard check is worth thirty seconds: Tab to a radio, use arrow keys to change selection, Tab to the button, press Enter. If focus order feels wrong or arrow keys do nothing, the markup is malformed somewhere—usually a label wrapping an input incorrectly or fieldsets nested inside each other.
If nothing happens on submit at all, the script almost certainly failed to load or ran before the DOM existed. Confirm the file path, then move the script tag to just before the closing body tag, or add the defer attribute to the script tag in the head.
Handling Multiple Answers, Randomization and Timers
The single-choice pattern above generalizes with small, targeted changes.
Multiple-answer questions use checkboxes instead of radios. Because several can be checked, the answer key becomes a set, and the comparison must check set equality rather than a single value. Store the key as a comma-separated string and compare sorted chosen values:
Note the mismatch this creates with the single-choice markup: a partially correct selection must be scored as wrong unless you define partial credit, and partial credit risks rewarding guessing. Decide the rule before writing it.
Randomization shuffles question order or answer order. Shuffling questions means reordering the fieldsets in the DOM after load, which is safe because keys travel inside each fieldset. Shuffling answers is riskier: it invalidates your CSS ::after markers if they assume position, though the value-based comparison handles it correctly. The standard technique—randomly swapping the last element with an earlier one in a NodeList converted to an array—is adequate. Avoid shuffling unless the quiz's integrity matters; for self-study, stable order helps learners.
Timers need a visible countdown and a defined end behavior. Start a time value when the first question gains focus, update a displayed element on an interval, and on expiry submit or lock the form. Two failure modes deserve attention: an interval that keeps running after submission (clear it in the handler) and clock display drifting from the actual score deadline if you derive one from the other. Use a single timestamp for the deadline and compute the remaining seconds from it each tick.
Reducing Repetition With a Data-Driven Build
Hand-writing twenty fieldsets is fine; hand-writing two hundred is not. The scaling move is to define questions as data and generate markup. A question becomes:
Then render each object as a fieldset with radios named q1, q2, and so on, and switch the scorer to read from the array rather than the DOM dataset. The critical step is escaping any HTML in prompt or choice strings before insertion—if you build markup with innerHTML, a choice containing an angle bracket or an ampersand breaks the page or, worse, executes if the data comes from users. The safe pattern is either escape special characters first or construct elements with document.createElement and textContent, which never interprets HTML.
Once questions live in data, moving them to a separate questions.json file is natural. Local files cannot be fetched with file:// URLs in mainstream browsers, so you must serve the folder over HTTP—a one-line local server from your language of choice works—or inline the data into the script. There is no browser-only trick that reliably avoids this restriction; treat the server requirement as the cost of external data.
Common Failures and How to Diagnose Them
Most broken quizzes fail in a handful of ways. The most frequent is mismatched names: two radios named q1 and q1 again is correct, but q1 and 1q silently splits a group and lets two answers coexist, and scoring then picks whichever comes first. Symptom: more selections than expected. Cause: name differences, often a stray space or capitalization.
The second is answer-key drift. You change a choice's text but not its value or data-answer, so the displayed correct answer no longer matches the scored one. Symptom: a visibly correct selection scores wrong. Fix: edit values once and derive labels from the same data.
The third is styling overriding feedback. A stylesheet rule with higher specificity than your .correct class, often a generic fieldset border rule placed later, prevents the green state from showing. Symptom: scoring works but nothing changes visually. Cause: CSS cascade order or specificity, not JavaScript. Check with the browser's element inspector to see which rule wins.
The fourth is scrolling-away results. On long quizzes, the result paragraph sits below the fold and users never see it. Move the result near the submit button, or scroll it into view programmatically after scoring. The accessible announcement does not help if the sighted user misses the message.
A fifth, subtler issue: radio groups inside separate forms. If each question is its own form, the browser treats groups independently and your script's single submit handler never fires for all of them. Keep one form wrapping all questions.
Choosing Between Static and Interactive Approaches
There is a real trade-off between a purely static quiz page and a JavaScript-driven one. Static HTML—questions with answers revealed by a CSS :checked selector or details elements—works without JavaScript, is trivially robust, and can be read by any device or archiver. Its limit is scoring: counting correct answers and computing a total is beyond what CSS alone does. If the quiz's purpose is self-checking with visible answers, static markup plus detail/summary elements is genuinely sufficient and cheaper to maintain.
JavaScript scoring adds totals, randomization, timers, and stored results. It also adds failure modes: a syntax error silently disables scoring, and a user with JavaScript blocked sees a quiz that never responds. Defensive design uses semantic markup that still displays sensibly with scripting off and a noscript notice where scoring is essential.
For most learning and internal-training quizzes, the hybrid chosen here—static markup, scripted scoring—is the sweet spot. For graded assessments with anti-cheating requirements, neither client-side pattern is sufficient, because all answer logic is visible in the page source. That is a scope limit worth stating plainly rather than engineering around.
FAQ
Can I store the quiz results without a server? Yes, with the browser's localStorage API for that user's own device—useful for practice tracking. It does not aggregate results across users, and clearing site data erases them. Real collection requires a server or form service.
Do I need a framework like React? No. A quiz of this size is well within plain HTML, CSS, and JavaScript. Frameworks earn their place when questions come from an API or the interface is one part of a larger app.
How many questions can one page hold before it gets unwieldy? Practically, dozens. The readable layout matters more than the count. Past roughly fifty, split into chapters or move to data-driven rendering so the source stays maintainable.
What about server-side grading for security? Client-side scoring reveals answers to anyone who views source. For anything that must resist inspection, grade on a server and send only questions to the browser—acknowledging that the questions themselves remain visible.