Unit 2: Semantic HTML and Forms - Practice Quiz

CSE326 — Internet Programming 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 Which HTML element represents the main content of a document?

Semantic HTML Elements Easy
A. <nav>
B. <main>
C. <aside>
D. <footer>

2 Which semantic element is intended for a group of navigation links?

Semantic HTML Elements Easy
A. <nav>
B. <article>
C. <header>
D. <section>

3 Which element is best suited for a self-contained blog post?

Semantic HTML Elements Easy
A. <aside>
B. <footer>
C. <address>
D. <article>

4 Which semantic element usually contains introductory content or a page heading?

Page Structure and Layout Easy
A. <header>
B. <figure>
C. <form>
D. <table>

5 Which element commonly contains copyright information at the bottom of a page?

Page Structure and Layout Easy
A. <footer>
B. <article>
C. <main>
D. <details>

6 Which attribute provides a text alternative for an image?

Accessibility Fundamentals Easy
A. alt
B. href
C. title
D. src

7 Why should heading elements such as <h1> and <h2> follow a logical order?

Accessibility Fundamentals Easy
A. To compress page images
B. To create table borders
C. To submit form values
D. To clarify content structure

8 Which HTML element creates a form for collecting user input?

Forms and Form Controls Easy
A. <input>
B. <fieldset>
C. <form>
D. <label>

9 Which element creates a multi-line text input control?

Forms and Form Controls Easy
A. <textarea>
B. <button>
C. <select>
D. <output>

10 Which element associates descriptive text with a form control?

Forms and Form Controls Easy
A. <label>
B. <legend>
C. <caption>
D. <summary>

11 Which input type is designed for entering an email address?

Input Types and Attributes Easy
A. number
B. search
C. password
D. email

12 Which input type hides the characters entered by a user?

Input Types and Attributes Easy
A. hidden
B. tel
C. text
D. password

13 Which attribute displays a short hint inside an empty input field?

Input Types and Attributes Easy
A. readonly
B. placeholder
C. autocomplete
D. required

14 Which attribute prevents a form from being submitted when an input is empty?

Form Validation Basics Easy
A. selected
B. required
C. disabled
D. multiple

15 Which attribute sets the minimum allowed value for a numeric input?

Form Validation Basics Easy
A. size
B. max
C. min
D. step

16 Which HTML element defines a table row?

Tables and Data Representation Easy
A. <td>
B. <caption>
C. <th>
D. <tr>

17 Which element defines a header cell in an HTML table?

Tables and Data Representation Easy
A. <tr>
B. <col>
C. <td>
D. <th>

18 What does WCAG primarily provide?

Accessibility Standards Easy
A. Web hosting instructions
B. Browser scripting rules
C. Database design standards
D. Web accessibility guidelines

19 Which practice makes an interactive page easier to use without a mouse?

Accessibility Standards Easy
A. Disabling tab selection
B. Removing visible focus
C. Using color alone
D. Supporting keyboard navigation

20 Which viewport setting helps a page match the width of a mobile device?

Responsive Content Structuring Easy
A. height=device-height
B. width=device-width
C. scale=desktop-size
D. 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?

Semantic HTML Elements Medium
A. <aside>
B. <article>
C. <main>
D. <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?

Semantic HTML Elements Medium
A. <nav>
B. <footer>
C. <aside>
D. <address>

23 A page contains a site header, navigation menu, primary content area, and site footer. Which structure best represents these regions?

Page Structure and Layout Medium
A. <div>, <nav>, <article>, <address>
B. <header>, <section>, <body>, <aside>
C. <header>, <nav>, <main>, <footer>
D. <head>, <menu>, <body>, <footer>

24 A document has one primary content region and several repeated product cards. Which use of <main> is most appropriate?

Page Structure and Layout Medium
A. Place <main> inside the document <head>
B. Place one <main> inside every product card
C. Place one <main> around the product grid
D. Place <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?

Accessibility Fundamentals Medium
A. Match the label for with the input id
B. Match the input name with the label id
C. Give both elements the same CSS class
D. Put the text in a nearby <span>

26 A decorative divider image adds no information and should be ignored by screen readers. Which markup is most appropriate?

Accessibility Fundamentals Medium
A. <img src="divider.png" alt="">
B. <img src="divider.png" aria-label="image">
C. <img src="divider.png" alt="divider">
D. <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?

Forms and Form Controls Medium
A. Wrap them in <section> with a <label>
B. Wrap them in <nav> with a heading
C. Wrap them in <fieldset> with a <legend>
D. Wrap them in <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?

Forms and Form Controls Medium
A. <button type="button">Help</button>
B. <button type="submit">Help</button>
C. <button type="reset">Help</button>
D. <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 Types and Attributes Medium
A. <input type="datetime">
B. <input type="text">
C. <input type="date">
D. <input type="time">

30 A quantity field must accept whole numbers from 1 through 10. Which control expresses these constraints most directly?

Input Types and Attributes Medium
A. <input type="text" minlength="1" maxlength="10">
B. <input type="number" min="1" max="10" step="1">
C. <input type="range" size="1" length="10">
D. <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?

Input Types and Attributes Medium
A. autocomplete="login-password"
B. autocomplete="password"
C. autocomplete="current-password"
D. autocomplete="new-password"

32 An optional email field uses type="email". What happens when a user enters not-an-email and submits the form?

Form Validation Basics Medium
A. The browser silently clears the field
B. The browser normally blocks submission
C. The browser submits it without checking
D. The browser converts it to plain text

33 A username must contain 4 to 12 ASCII letters or digits. Which input applies this rule using built-in HTML validation?

Form Validation Basics Medium
A. <input required pattern="[A-Za-z0-9]{4,12}">
B. <input validate="letters-digits" min="4" max="12">
C. <input minlength="4" maxlength="12" format="alphanumeric">
D. <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?

Form Validation Basics Medium
A. Client-side checks can be bypassed or manipulated
B. HTML attributes cannot validate numeric values
C. Server validation automatically improves page layout
D. HTML validation only works with CSS enabled

35 A table lists products in rows with columns for name, price, and stock. Which markup best identifies the column headings?

Tables and Data Representation Medium
A. Use <th scope="col"> cells
B. Use <td scope="column"> cells
C. Use <thead scope="column"> cells
D. Use <caption scope="col"> cells

36 A data table needs a short title that explains what its values represent. Which element should provide this title?

Tables and Data Representation Medium
A. <caption>
B. <legend>
C. <title>
D. <summary>

37 A custom control can be focused with the keyboard but responds only to mouse clicks. Which change most directly improves keyboard accessibility?

Accessibility Standards Medium
A. Increase the control's color contrast
B. Add a larger hover effect
C. Add a longer tooltip description
D. Handle Enter and Space activation

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?

Accessibility Standards Medium
A. Add tabindex="-1" to the entire form
B. Add aria-hidden="true" to the status region
C. Add aria-live="polite" to the status region
D. Add 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?

Responsive Content Structuring Medium
A. Place the table in a horizontally scrollable container
B. Convert every table cell into a separate paragraph
C. Scale the entire table using a fixed transform
D. Hide all columns except the first by default

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?

Responsive Content Structuring Medium
A. The usemap and ismap attributes
B. The width and height attributes
C. The loading and decoding attributes
D. The 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?

Semantic HTML Elements Hard
A. Use a <div> for each review, because user-generated content is non-semantic
B. Use a <section> for each review, with all headings outside the sections
C. Use an <aside> for each review, because reviews supplement the product details
D. Use an <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?

Page Structure and Layout Hard
A. Nest all three <main> elements inside one visible application <main>
B. Replace each <main> with <section> and assign role="main" to all three
C. Give every <main> a unique role and hide inactive views with opacity: 0
D. Give every <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?

Accessibility Fundamentals Hard
A. Delete Invoice 42
B. Remove item
C. Invoice 42 Delete
D. 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?

Forms and Form Controls Hard
A. <form id="order"></form><input name="qty" form="order" required>
B. <form name="order"></form><input name="qty" for="order" required>
C. <form id="order"></form><input name="qty" owner="order" required>
D. <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?

Input Types and Attributes Hard
A. It has a step mismatch because valid values are 0.2 + n \times 0.5
B. It is valid because 1.0 is evenly divisible by the step value
C. It is valid because min and step are checked independently
D. It has a range error because decimal values require 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?

Form Validation Basics Hard
A. Both inputs remain enabled, but neither participates in validation
B. Both inputs become disabled because disabledness always propagates
C. The legend input remains enabled, while the body input is disabled
D. The legend input becomes disabled, while the body input remains enabled

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?

Tables and Data Representation Hard
A. Assign identical name values to the related headers and the associated data cell
B. Assign id values to the headers and list them in the cell's headers attribute
C. Assign aria-label to the data cell and remove the complex header relationships
D. Assign 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?

Accessibility Standards Hard
A. Name, Role, Value, because native controls never expose their roles automatically
B. Sensory Characteristics, because the controls rely exclusively on their horizontal position
C. Information and Relationships, because the visual grouping lacks a programmatic equivalent
D. Error Identification, because every group heading must also describe possible errors

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?

Responsive Content Structuring Hard
A. Positive tabindex values should synchronize keyboard focus with each responsive visual arrangement
B. An aria-flowto chain should replace source order because CSS Grid removes document semantics
C. The desktop grid order should be copied into the DOM because visual order always defines the reading sequence
D. The DOM should preserve the logical reading order because CSS placement does not reliably change assistive-technology order

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?

Semantic HTML Elements Hard
A. Wrap only the social-media links in <nav> because external links require landmarks
B. Wrap the entire footer in <nav> because it contains at least one hyperlink
C. Wrap every link individually in <nav> so each receives navigation semantics
D. Wrap the privacy and terms links in <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?

Page Structure and Layout Hard
A. Use <h1>Datasets</h1> and <h1>Archived Sets</h1>
B. Use <header>Datasets</header> and <header>Archived Sets</header>
C. Use <hgroup>Datasets</hgroup> and <hgroup>Archived Sets</hgroup>
D. Use <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?

Accessibility Fundamentals Hard
A. Set role="alert" on the input and copy the message into its placeholder
B. Set aria-errormessage on the label and remove the input's native required state
C. Set aria-required="true" on the message and reference the input with aria-controls
D. Set 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?

Forms and Form Controls Hard
A. a=1, b=2, and c=
B. a=1 and c=on
C. a=1 and b=2
D. 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?

Input Types and Attributes Hard
A. alice@example.com, invalid-address
B. alice@example.com; bob@example.org
C. alice@example.com, bob@example.org
D. 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?

Form Validation Basics Hard
A. ABC
B. XABC
C. ABc
D. 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?

Tables and Data Representation Hard
A. Use <td colspan="4" headers="2024">2024</td> and the equivalent cell for 2025
B. Use <th rowspan="4" scope="col">2024</th> and the equivalent header for 2025
C. Use <th colspan="4" scope="rowgroup">2024</th> and the equivalent header for 2025
D. Use <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?

Accessibility Standards Hard
A. Space the targets so a 24-CSS-pixel-diameter circle around each target does not intersect another target
B. Place the targets inside one 80 \times 20 CSS-pixel toolbar with no gaps between them
C. Increase each icon's device-pixel resolution while keeping its CSS dimensions unchanged
D. Add 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?

Responsive Content Structuring Hard
A. It uses the last matching <source> because later sources override earlier responsive rules
B. It uses the first matching <source>, then selects a candidate from that source's srcset
C. It downloads the <img> resource first, then replaces it with every matching source in sequence
D. It combines both matching 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?

Forms and Form Controls Hard
A. The request targets /draft but excludes the button because formaction replaces its name
B. The request targets /draft and includes the successful pair mode=draft
C. The request targets /default and excludes the button because buttons are never successful
D. The request targets /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?

Form Validation Basics Hard
A. The input becomes valid automatically when the input event detects a valid value
B. The input remains invalid only until focus leaves the control for the first time
C. The input remains invalid until setCustomValidity("") clears the custom error
D. The input becomes valid automatically when all native validity flags become false