Unit 2: Semantic HTML and Forms - Practice Quiz
1 Which HTML element represents the main content of a document?
<nav>
<main>
<aside>
<footer>
2 Which semantic element is intended for a group of navigation links?
<nav>
<article>
<header>
<section>
3 Which element is best suited for a self-contained blog post?
<aside>
<footer>
<address>
<article>
4 Which semantic element usually contains introductory content or a page heading?
<header>
<figure>
<form>
<table>
5 Which element commonly contains copyright information at the bottom of a page?
<footer>
<article>
<main>
<details>
6 Which attribute provides a text alternative for an image?
alt
href
title
src
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?
<input>
<fieldset>
<form>
<label>
9 Which element creates a multi-line text input control?
<textarea>
<button>
<select>
<output>
10 Which element associates descriptive text with a form control?
<label>
<legend>
<caption>
<summary>
11 Which input type is designed for entering an email address?
number
search
password
email
12 Which input type hides the characters entered by a user?
hidden
tel
text
password
13 Which attribute displays a short hint inside an empty input field?
readonly
placeholder
autocomplete
required
14 Which attribute prevents a form from being submitted when an input is empty?
selected
required
disabled
multiple
15 Which attribute sets the minimum allowed value for a numeric input?
size
max
min
step
16 Which HTML element defines a table row?
<td>
<caption>
<th>
<tr>
17 Which element defines a header cell in an HTML table?
<tr>
<col>
<td>
<th>
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?
height=device-height
width=device-width
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?
<aside>
<article>
<main>
<section>
22 A blog post includes a box containing related links and a short author biography. Which semantic element is most appropriate for the box?
<nav>
<footer>
<aside>
<address>
23 A page contains a site header, navigation menu, primary content area, and site footer. Which structure best represents these regions?
<div>, <nav>, <article>, <address>
<header>, <section>, <body>, <aside>
<header>, <nav>, <main>, <footer>
<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 the document <head>
<main> inside every product card
<main> around the product grid
<main> around the navigation menu
25 A form visually places the text "Email address" next to an email field. Which implementation best associates the text with the field?
for with the input id
name with the label id
<span>
26 A decorative divider image adds no information and should be ignored by screen readers. Which markup is most appropriate?
<img src="divider.png" alt="">
<img src="divider.png" aria-label="image">
<img src="divider.png" alt="divider">
<img src="divider.png" title="decorative">
27 A registration form contains a set of radio buttons for selecting one shipping method. Which markup provides the best semantic grouping?
<section> with a <label>
<nav> with a heading
<fieldset> with a <legend>
<div> with a placeholder
28 A button inside a form opens a help dialog and must not submit the form. Which declaration should be used?
<button type="button">Help</button>
<button type="submit">Help</button>
<button type="reset">Help</button>
<button type="form">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="datetime">
<input type="text">
<input type="date">
<input type="time">
30 A quantity field must accept whole numbers from 1 through 10. Which control expresses these constraints most directly?
<input type="text" minlength="1" maxlength="10">
<input type="number" min="1" max="10" step="1">
<input type="range" size="1" length="10">
<input type="numeric" low="1" high="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="password"
autocomplete="current-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 validate="letters-digits" min="4" max="12">
<input minlength="4" maxlength="12" format="alphanumeric">
<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?
<th scope="col"> cells
<td scope="column"> cells
<thead scope="column"> cells
<caption 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?
tabindex="-1" to the entire form
aria-hidden="true" to the status region
aria-live="polite" to the status region
role="presentation" to the message
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?
usemap and ismap attributes
width and height 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?
<div> for each review, because user-generated content is non-semantic
<section> for each review, with all headings outside the sections
<aside> for each review, because reviews supplement the product details
<article> for each review, with its heading and metadata inside
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> elements inside one visible application <main>
<main> with <section> and assign role="main" to all three
<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?
Delete Invoice 42
Remove item
Invoice 42 Delete
Remove item 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 name="order"></form><input name="qty" for="order" required>
<form id="order"></form><input name="qty" owner="order" required>
<form name="order"></form><input name="qty" target="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?
0.2 + n \times 0.5
1.0 is evenly divisible by the step value
min and step are checked independently
step="any"
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?
name values to the related headers and the associated data cell
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
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?
tabindex values should synchronize keyboard focus with each responsive visual arrangement
aria-flowto chain should replace source order because CSS Grid removes document semantics
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 external links require landmarks
<nav> because it contains at least one hyperlink
<nav> so each receives navigation semantics
<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>
<header>Datasets</header> and <header>Archived Sets</header>
<hgroup>Datasets</hgroup> and <hgroup>Archived Sets</hgroup>
<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?
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
aria-invalid="true" on the input and reference the message with aria-describedby
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, b=2, and c=
a=1 and c=on
a=1 and b=2
b=2 and c=on
54
For <input type="email" multiple required>, which nonempty value satisfies the type-specific syntax requirement, assuming ordinary ASCII addresses?
alice@example.com, invalid-address
alice@example.com; bob@example.org
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
XABC
ABc
ABC7
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?
<td colspan="4" headers="2024">2024</td> and the equivalent cell for 2025
<th rowspan="4" scope="col">2024</th> and the equivalent header for 2025
<th colspan="4" scope="rowgroup">2024</th> and the equivalent header for 2025
<th colspan="4" scope="colgroup">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
80 \times 20 CSS-pixel toolbar with no gaps between them
aria-label values so target dimensions no longer apply to the icon controls
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?
/draft but excludes the button because formaction replaces its name
/draft and includes the successful pair mode=draft
/default and excludes the button because buttons are never successful
/default and includes the pair formaction=/draft
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 →