HTML MCQ Set 1: Beginner

Thirty multiple choice questions on document structure, elements, text, links, lists and images. Questions only - verify each answer by building it.

How to use this set

These are questions only. No answer key is given, and that is deliberate.

For almost every question here you can settle the answer definitively in under a minute: write the markup, open it in a browser, and look at the Elements panel or run the validator. An answer you established yourself that way is worth considerably more than one you read at the bottom of a page.

Where a question is about behaviour, test it. Where it is about validity, validate it. Where it is about what a screen reader announces, check the accessibility pane in DevTools.

Thirty questions. Allow forty minutes.

Document structure

  1. What is the only purpose of <!DOCTYPE html> in a modern browser?
    a) It declares the HTML version   b) It switches the browser into standards mode   c) It validates the document   d) It loads the default stylesheet
  2. Which element must be the root of every HTML document?
    a) body   b) head   c) html   d) document
  3. Which of these belongs in the head rather than the body?
    a) h1   b) meta   c) footer   d) figure
  4. Where in the document should <meta charset="utf-8"> appear, and why does the position matter?
    a) Anywhere in the head   b) First in the head, before any text content   c) At the end of the body   d) Immediately after the doctype, outside the head
  5. What happens if you place an h1 element inside the head?
    a) It renders in the head   b) It is ignored   c) The head ends and the body begins at that point   d) The document fails to parse
  6. What does the lang attribute on html affect?
    a) Only the browser interface language   b) Screen reader pronunciation, translation offers and hyphenation   c) The character encoding   d) Nothing, it is advisory only

Elements and attributes

  1. In <a href="/x">Link</a>, how many tags, elements and attributes are there?
    a) 1, 1, 1   b) 2, 1, 1   c) 2, 2, 1   d) 1, 2, 2
  2. Which of these is a void element?
    a) p   b) span   c) img   d) li
  3. What does <input required="false"> do?
    a) Makes the field optional   b) Makes the field required   c) Is a parse error   d) Is ignored entirely
  4. Which attribute may appear on any element?
    a) href   b) src   c) class   d) type
  5. How many elements in a document may share the same id value?
    a) Any number   b) Two   c) One   d) One per parent element
  6. Which prefix must a custom attribute use to be valid?
    a) x-   b) custom-   c) data-   d) my-

Text elements

  1. What decides which heading level to use?
    a) The required font size   b) The position in the document outline   c) The importance of the text   d) The length of the heading
  2. Which pair carries meaning rather than only appearance?
    a) b and i   b) strong and em   c) span and div   d) small and big
  3. What does the browser do with a run of twenty spaces in the source?
    a) Renders all twenty   b) Collapses them to one space   c) Removes them entirely   d) Renders them as a tab
  4. Which element preserves whitespace exactly as written?
    a) code   b) pre   c) blockquote   d) samp
  5. What does hr mean semantically?
    a) A horizontal rule for decoration   b) A thematic break in the content   c) A section divider for layout   d) A page break for printing
  6. Which is correct for a chemical formula such as water?
    a) H<small>2</small>O   b) H<sub>2</sub>O   c) H<sup>2</sup>O   d) H<em>2</em>O
  7. What is the difference between the cite element and the cite attribute?
    a) None, they are the same feature   b) The element is displayed, the attribute is not   c) The attribute is displayed, the element is not   d) Both are displayed in different places
  1. From a page at /blog/2026/rain.html, where does href="../index.html" point?
    a) /index.html   b) /blog/index.html   c) /blog/2026/index.html   d) /blog/2026/../index.html
  2. What does a leading slash in href="/about" mean?
    a) The parent folder   b) The current folder   c) The root of the site   d) The root of the disk
  3. Which href resolves to a different host?
    a) /images/logo.png   b) //images/logo.png   c) ./images/logo.png   d) images/logo.png
  4. Why should target="_blank" be paired with rel="noopener"?
    a) To improve performance   b) To stop the new page getting a reference to yours   c) To pass ranking credit   d) To keep the referrer header
  5. An anchor with no href attribute is:
    a) A link that goes to the current page   b) Not focusable and not announced as a link   c) Invalid markup   d) Focusable but not clickable
  6. Which link text is most useful when read out of context?
    a) Click here   b) Read more   c) Download the 2026 fee structure   d) This link

Lists and images

  1. You are marking up a recipe method where the steps must happen in order. Which element?
    a) ul   b) ol   c) dl   d) menu
  2. Where does a nested list belong?
    a) Directly inside the parent ul   b) Inside the li it belongs to   c) After the closing </ul>   d) Inside a div within the ul
  3. What is the difference between a missing alt attribute and alt=""?
    a) None   b) Missing is announced as the file name; empty is skipped   c) Empty is announced as blank; missing is skipped   d) Both cause a validation error
  4. Why do width and height attributes matter on an img?
    a) They set the display size   b) They let the browser reserve space and prevent layout shift   c) They are required for validation   d) They improve image quality
  5. Which format is most appropriate for a logo that must stay sharp at any size?
    a) JPEG   b) PNG   c) SVG   d) GIF

How to verify your answers

Question typeHow to settle it
Structure and parsingWrite it, open the Elements panel, compare with your source
ValidityRun it through the W3C validator
Path resolutionBuild the folder structure and click the link
AnnouncementRead the computed name in the DevTools accessibility pane
Rendering behaviourTry it and look

Practice

  1. Work through all thirty, writing down your answer and your confidence for each.
  2. Verify every answer in the browser. Note which ones you were confident about and wrong.
  3. For each one you got wrong, find the note in this path that covers it and reread that section.
  4. Write five new questions of your own at the same level.

Useful resources

Hand picked references for this topic
Written by Lorens Mishra

Default administrator account created by the installer.

Continue reading

All HTML notes →
HTML

Project Exams

Five larger assessments where the deliverable is a working site. Requirements, constraints and a rubric for each.

Read more

Discussion

0 comments
Sign in to join the discussion.

No comments yet. Be the first to say something.