Unit 2: Semantic HTML and Forms - Practice Quiz
1 Which HTML element represents the main content of a document?
<aside>
<footer>
<nav>
<main>
2 Which semantic element is intended for a group of navigation links?
<nav>
<header>
<article>
<section>
3 Which element is best suited for a self-contained blog post?
<footer>
<address>
<aside>
<article>
4 Which semantic element usually contains introductory content or a page heading?
<table>
<figure>
<form>
<header>
5 Which element commonly contains copyright information at the bottom of a page?
<details>
<main>
<article>
<footer>
6 Which attribute provides a text alternative for an image?
href
src
alt
title
7
Why should heading elements such as <h1> and <h2> follow a logical order?
8 Which HTML element creates a form for collecting user input?
<label>
<form>
<input>
<fieldset>
9 Which element creates a multi-line text input control?
<textarea>
<button>
<select>
<output>
10 Which element associates descriptive text with a form control?
<summary>
<caption>
<label>
<legend>
11 Which input type is designed for entering an email address?
email
number
search
password
12 Which input type hides the characters entered by a user?
tel
password
hidden
text
13 Which attribute displays a short hint inside an empty input field?
required
placeholder
autocomplete
readonly
14 Which attribute prevents a form from being submitted when an input is empty?
disabled
multiple
selected
required
15 Which attribute sets the minimum allowed value for a numeric input?
step
max
min
size
16 Which HTML element defines a table row?
<td>
<caption>
<th>
<tr>
17 Which element defines a header cell in an HTML table?
<th>
<td>
<col>
<tr>
18 What does WCAG primarily provide?
19 Which practice makes an interactive page easier to use without a mouse?
20 Which viewport setting helps a page match the width of a mobile device?
width=device-width
height=device-height
scale=desktop-size
width=fixed-width
21 A news page displays several stories that could each be distributed independently through an RSS feed. Which element should wrap each story?
<section>
<article>
<aside>
<main>
22 A blog post includes a box containing related links and a short author biography. Which semantic element is most appropriate for the box?
<aside>
<address>
<nav>
<footer>
23 A page contains a site header, navigation menu, primary content area, and site footer. Which structure best represents these regions?
<header>, <nav>, <main>, <footer>
<header>, <section>, <body>, <aside>
<div>, <nav>, <article>, <address>
<head>, <menu>, <body>, <footer>
24
A document has one primary content region and several repeated product cards. Which use of <main> is most appropriate?
<main> inside every product card
<main> inside the document <head>
<main> around the navigation menu
<main> around the product grid
25 A form visually places the text "Email address" next to an email field. Which implementation best associates the text with the field?
<span>
name with the label id
for with the input id
26 A decorative divider image adds no information and should be ignored by screen readers. Which markup is most appropriate?
<img src="divider.png" title="decorative">
<img src="divider.png" alt="">
<img src="divider.png" aria-label="image">
<img src="divider.png" alt="divider">
27 A registration form contains a set of radio buttons for selecting one shipping method. Which markup provides the best semantic grouping?
<div> with a placeholder
<section> with a <label>
<fieldset> with a <legend>
<nav> with a heading
28 A button inside a form opens a help dialog and must not submit the form. Which declaration should be used?
<button type="reset">Help</button>
<button type="form">Help</button>
<button type="button">Help</button>
<button type="submit">Help</button>
29 A form asks users to enter a meeting date and should display a browser-provided date control when supported. Which input is most suitable?
<input type="time">
<input type="date">
<input type="text">
<input type="datetime">
30 A quantity field must accept whole numbers from 1 through 10. Which control expresses these constraints most directly?
<input type="numeric" low="1" high="10">
<input type="text" minlength="1" maxlength="10">
<input type="number" min="1" max="10" step="1">
<input type="range" size="1" length="10">
31 A login page should allow password managers to recognize a field as the user's existing password. Which attribute value is most appropriate?
autocomplete="login-password"
autocomplete="current-password"
autocomplete="password"
autocomplete="new-password"
32
An optional email field uses type="email". What happens when a user enters not-an-email and submits the form?
33 A username must contain 4 to 12 ASCII letters or digits. Which input applies this rule using built-in HTML validation?
<input required pattern="[A-Za-z0-9]{4,12}">
<input minlength="4" maxlength="12" format="alphanumeric">
<input validate="letters-digits" min="4" max="12">
<input required type="username" size="4-12">
34
A developer adds required, min, and pattern attributes to a form. Why is server-side validation still necessary?
35 A table lists products in rows with columns for name, price, and stock. Which markup best identifies the column headings?
<caption scope="col"> cells
<thead scope="column"> cells
<td scope="column"> cells
<th scope="col"> cells
36 A data table needs a short title that explains what its values represent. Which element should provide this title?
<caption>
<legend>
<title>
<summary>
37 A custom control can be focused with the keyboard but responds only to mouse clicks. Which change most directly improves keyboard accessibility?
38 A status message appears after an asynchronous form submission, but keyboard focus should remain on the submit button. Which technique can announce the update to screen readers?
role="presentation" to the message
tabindex="-1" to the entire form
aria-hidden="true" to the status region
aria-live="polite" to the status region
39 A wide data table must remain usable on a narrow screen without removing columns. Which approach best preserves the table's relationships?
40 An article image has several optimized files for different viewport widths. Which HTML feature lets the browser choose an appropriate file based on layout and pixel density?
width and height attributes
usemap and ismap attributes
loading and decoding attributes
srcset and sizes attributes
41 A page lists several product reviews. Each review has its own heading, author, publication date, and body, and could be syndicated independently. Which structure best represents each review?
<aside> for each review, because reviews supplement the product details
<div> for each review, because user-generated content is non-semantic
<article> for each review, with its heading and metadata inside
<section> for each review, with all headings outside the sections
42
A single-page application keeps three routed views in the DOM, each containing a <main> element. Only the active view should contribute to the accessibility tree. Which implementation is conforming?
<main> with <section> and assign role="main" to all three
<main> elements inside one visible application <main>
<main> a unique role and hide inactive views with opacity: 0
<main> a unique id and hide inactive views with hidden
43
Given <button aria-label="Remove item" aria-labelledby="row7 action-text"><span id="action-text">Delete</span></button> and an element with id="row7" whose text is Invoice 42, what accessible name should the button receive?
Remove item Delete
Delete Invoice 42
Remove item
Invoice 42 Delete
44 An input must visually appear outside a form but still participate in that form's submission and validation. Which markup provides the required native association?
<form id="order"></form><input name="qty" form="order" required>
<form id="order"></form><input name="qty" owner="order" required>
<form name="order"></form><input name="qty" target="order" required>
<form name="order"></form><input name="qty" for="order" required>
45
Consider <input type="number" min="0.2" step="0.5" value="1.0">. Assuming the value parses successfully, which statement describes its constraint-validation state?
step="any"
1.0 is evenly divisible by the step value
min and step are checked independently
0.2 + n \times 0.5
46
A <fieldset disabled> contains several required controls. One required input is inside the fieldset's first <legend>, while another is in the fieldset body. Which statement is correct?
47
A data cell belongs simultaneously to a row header and two noncontiguous column headers in a complex table. The relationships cannot be represented reliably with simple scope values. Which technique is most appropriate?
id values to the headers and list them in the cell's headers attribute
aria-label to the data cell and remove the complex header relationships
name values to the related headers and the associated data cell
scope="row col" to the cell and place header text in its title attribute
48 A visual form presents three adjacent controls under one heading, but the heading-control relationship exists only through spacing and font weight. Which WCAG principle is most directly violated?
49
A desktop layout visually places <aside> before <main> using CSS Grid, although <main> comes first in the DOM. On mobile, the visual layout follows DOM order. What is the strongest accessibility conclusion?
aria-flowto chain should replace source order because CSS Grid removes document semantics
tabindex values should synchronize keyboard focus with each responsive visual arrangement
50
A site footer contains copyright text, a postal address, social-media links, and links to privacy and terms pages. Which use of <nav> is most semantically appropriate?
<nav> because it contains at least one hyperlink
<nav> so each receives navigation semantics
<nav> because external links require landmarks
<nav> if they form a significant navigation group
51
A document has <h1>Research Portal</h1>, followed by a top-level <section> titled Datasets, which contains a nested section titled Archived Sets. Which heading markup expresses the hierarchy without relying on the obsolete document-outline algorithm?
<h1>Datasets</h1> and <h1>Archived Sets</h1>
<hgroup>Datasets</hgroup> and <hgroup>Archived Sets</hgroup>
<header>Datasets</header> and <header>Archived Sets</header>
<h2>Datasets</h2> and <h3>Archived Sets</h3>
52
After an invalid form submission, a script displays a persistent message explaining the error for email. Which update best communicates both the invalid state and the message association to assistive technology?
aria-invalid="true" on the input and reference the message with aria-describedby
role="alert" on the input and copy the message into its placeholder
aria-errormessage on the label and remove the input's native required state
aria-required="true" on the message and reference the input with aria-controls
53
A submitted form contains <input name="a" value="1" readonly>, <input name="b" value="2" disabled>, and <input type="checkbox" name="c" checked>. Ignoring encoding details, which name-value pairs are successful controls?
a=1 and b=2
a=1 and c=on
b=2 and c=on
a=1, b=2, and c=
54
For <input type="email" multiple required>, which nonempty value satisfies the type-specific syntax requirement, assuming ordinary ASCII addresses?
alice@example.com; bob@example.org
alice@example.com, invalid-address
alice@example.com, bob@example.org
alice@example.com bob@example.org
55
An input uses pattern="[A-Z]{3}". Which value satisfies the pattern constraint when the input is nonempty?
ABC
ABC7
XABC
ABc
56
A table has column groups 2024 and 2025, each spanning four quarter columns. Which markup best establishes each year header as applying to its complete column group?
<th colspan="4" scope="colgroup">2024</th> and the equivalent header for 2025
<th rowspan="4" scope="col">2024</th> and the equivalent header for 2025
<td colspan="4" headers="2024">2024</td> and the equivalent cell for 2025
<th colspan="4" scope="rowgroup">2024</th> and the equivalent header for 2025
57
Under WCAG 2.2 Success Criterion 2.5.8 at Level AA, four small inline icon targets are each 20 \times 20 CSS pixels. Which arrangement can satisfy the target-size requirement without enlarging the icons?
24-CSS-pixel-diameter circle around each target does not intersect another target
aria-label values so target dimensions no longer apply to the icon controls
80 \times 20 CSS-pixel toolbar with no gaps between them
58
A <picture> contains two <source> elements whose media conditions both match, followed by an <img> fallback. How does the browser choose the image resource?
<source> because later sources override earlier responsive rules
<source>, then selects a candidate from that source's srcset
<img> resource first, then replaces it with every matching source in sequence
srcset values, then downloads the candidate with the largest width
59
A form has action="/default" and contains <button name="mode" value="draft" formaction="/draft">Save draft</button>. When that button submits the form, which behavior occurs?
/default and excludes the button because buttons are never successful
/draft and includes the successful pair mode=draft
/default and includes the pair formaction=/draft
/draft but excludes the button because formaction replaces its name
60
A script calls input.setCustomValidity("Code already used"). The user later enters a value that satisfies every native constraint, but the script takes no further action. What is the resulting validation state?
input event detects a valid value
setCustomValidity("") clears the custom error
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →