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. <aside>
B. <footer>
C. <nav>
D. <main>

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

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

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

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

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

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

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

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

6 Which attribute provides a text alternative for an image?

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

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

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

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

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

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. <summary>
B. <caption>
C. <label>
D. <legend>

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

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

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

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

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

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

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

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

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

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

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. <th>
B. <td>
C. <col>
D. <tr>

18 What does WCAG primarily provide?

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

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

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

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

Responsive Content Structuring Easy
A. width=device-width
B. height=device-height
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. <section>
B. <article>
C. <aside>
D. <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?

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

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. <header>, <nav>, <main>, <footer>
B. <header>, <section>, <body>, <aside>
C. <div>, <nav>, <article>, <address>
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 one <main> inside every product card
B. Place <main> inside the document <head>
C. Place <main> around the navigation menu
D. Place one <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?

Accessibility Fundamentals Medium
A. Put the text in a nearby <span>
B. Match the input name with the label id
C. Give both elements the same CSS class
D. Match the label 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?

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

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

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

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="numeric" low="1" high="10">
B. <input type="text" minlength="1" maxlength="10">
C. <input type="number" min="1" max="10" step="1">
D. <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?

Input Types and Attributes Medium
A. autocomplete="login-password"
B. autocomplete="current-password"
C. autocomplete="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 submits it without checking
B. The browser silently clears the field
C. The browser converts it to plain text
D. The browser normally blocks submission

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 minlength="4" maxlength="12" format="alphanumeric">
C. <input validate="letters-digits" min="4" max="12">
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. Server validation automatically improves page layout
B. HTML validation only works with CSS enabled
C. HTML attributes cannot validate numeric values
D. Client-side checks can be bypassed or manipulated

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 <caption scope="col"> cells
B. Use <thead scope="column"> cells
C. Use <td scope="column"> cells
D. Use <th 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. Add a longer tooltip description
B. Handle Enter and Space activation
C. Add a larger hover effect
D. Increase the control's color contrast

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 role="presentation" to the message
B. Add tabindex="-1" to the entire form
C. Add aria-hidden="true" to the status region
D. Add 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?

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

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 width and height attributes
B. The usemap and ismap 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 an <aside> for each review, because reviews supplement the product details
B. Use a <div> for each review, because user-generated content is non-semantic
C. Use an <article> for each review, with its heading and metadata inside
D. Use a <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?

Page Structure and Layout Hard
A. Replace each <main> with <section> and assign role="main" to all three
B. Nest all three <main> elements inside one visible application <main>
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. Remove item Delete
B. Delete Invoice 42
C. Remove item
D. 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?

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

Input Types and Attributes Hard
A. It has a range error because decimal values require step="any"
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 step mismatch because valid values are 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?

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

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 id values to the headers and list them in the cell's headers attribute
B. Assign aria-label to the data cell and remove the complex header relationships
C. Assign identical name values to the related headers and the associated data cell
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. Error Identification, because every group heading must also describe possible errors
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. Name, Role, Value, because native controls never expose their roles automatically

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. The desktop grid order should be copied into the DOM because visual order always defines the reading sequence
B. An aria-flowto chain should replace source order because CSS Grid removes document semantics
C. Positive tabindex values should synchronize keyboard focus with each responsive visual arrangement
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 the entire footer in <nav> because it contains at least one hyperlink
B. Wrap every link individually in <nav> so each receives navigation semantics
C. Wrap only the social-media links in <nav> because external links require landmarks
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 <hgroup>Datasets</hgroup> and <hgroup>Archived Sets</hgroup>
C. Use <header>Datasets</header> and <header>Archived Sets</header>
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 aria-invalid="true" on the input and reference the message with aria-describedby
B. Set role="alert" on the input and copy the message into its placeholder
C. Set aria-errormessage on the label and remove the input's native required state
D. Set 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?

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

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

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

Accessibility Standards Hard
A. Space the targets so a 24-CSS-pixel-diameter circle around each target does not intersect another target
B. Add aria-label values so target dimensions no longer apply to the icon controls
C. Place the targets inside one 80 \times 20 CSS-pixel toolbar with no gaps between them
D. Increase each icon's device-pixel resolution while keeping its CSS dimensions unchanged

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 /default and excludes the button because buttons are never successful
B. The request targets /draft and includes the successful pair mode=draft
C. The request targets /default and includes the pair formaction=/draft
D. The request targets /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?

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