HTML Quiz
A short HTML quiz - structure, attributes, semantic elements, accessibility.
Sample questions
EXAMPLE
# HTML quiz 1) Which tag should wrap the primary content of a page? a) <div> b) <main> c) <section> d) <body> 2) The viewport meta tag is for: a) SEO ranking b) telling mobile browsers to use the device width as the layout width c) lazy loading d) browser caching 3) Which input type provides a date picker on supporting browsers? a) type='datetime-local' or type='date' b) type='text' with regex c) type='picker' d) type='calendar' 4) The alt attribute on <img>: a) is optional b) is required and describes the image for screen readers and broken-image fallback c) controls hover text d) is a deprecated attribute 5) When should you use a <button> vs <a>? a) interchangeable b) button for actions (submit, toggle), anchor for navigation (URL change) c) only button for forms d) anchor for everything 6) Which is the modern way to lazy-load an image? a) <img loading='lazy' ...> b) JavaScript IntersectionObserver only c) <img data-src='...'> d) display: none 7) Block-level vs inline elements: a) block elements take a full line by default, inline elements flow with text b) the same thing c) only matters for tables d) defined by ARIA roles 8) The right element for a non-modal expandable section is: a) <details> + <summary> b) <div> with JS toggling display c) <accordion> d) <expand> Answers: 1b, 2b, 3a, 4b, 5b, 6a, 7a, 8a.
Why it matters
Semantics + accessibility + the right input types win you most HTML interviews. If you nail those, you avoid the most common production bugs - keyboard-only users blocked, screen readers confused, mobile layouts broken.
Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.
Example
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Quiz</title>
</head>
<body>
<h1>HTML Quiz</h1>
<p>This is a demo page for the "HTML Quiz" lesson.</p>
</body>
</html>
Try it Yourself »
Exercise
How many questions are in the quick "Test yourself" quiz at the end of each lesson?
questions
A single digit.
Discussion
Loading…