HTML Fundamentals MCQs for NSCT

By the NSCT Exam Editorial Team · Updated 2026-11-24 · Facts checked against official sources on 2026-11-24

HTML Fundamentals covers how HTML (HyperText Markup Language) gives a page its structure and meaning: semantic elements, forms, attributes and the accessibility that follows from using them correctly. It is topic 3 of the Web Development area, which carries 10% of the NSCT according to HEC's Areas of Competencies. In 2026 candidates averaged 54.1% accuracy in this area, per the HEC NSCT report and APP.

This page follows the HTML Living Standard maintained by WHATWG, which is what browsers implement today. Older books list "HTML5" or XHTML rules that no longer apply, so treat the standard as the final word.

Semantic tags

A semantic element says what its content is, not how it looks. Browsers, search engines and screen readers use that meaning; CSS handles the look.

<header>Site name and logo</header>
<nav>Main menu links</nav>
<main>
  <article>
    <h1>Blog post title</h1>
    <section><h2>First part</h2> ...</section>
  </article>
  <aside>Related posts</aside>
</main>
<footer>Copyright</footer>
Element Use it for
<main> The page's unique content (one visible per page)
<article> Self-contained content that could stand alone, such as a post or a comment
<section> A thematic group, usually with a heading
<div> / <span> No meaning; styling or scripting hooks only
<strong> / <b> Strong importance / attention without importance

Obsolete elements such as <center>, <font> and <marquee> are non-conforming; use CSS instead. <small>, <b> and <i> are still valid, but they now carry specific meanings.

Exam angle: expect "article or section?" and "which element is obsolete?" questions.

Forms

A form collects input and submits it to the URL in action using method. Only controls with a name are submitted, as name=value pairs.

<form action="/apply" method="post" enctype="multipart/form-data">
  <label for="cnic">CNIC</label>
  <input id="cnic" name="cnic" pattern="[0-9]{13}" required>
  <input type="file" name="transcript">
  <button>Submit</button>
</form>
GET POST
Data goes in URL query string (?q=web+dev) Request body
Good for Searches and filters Creating or changing data, file uploads
Bookmarkable Yes No

Key facts: a <button> with no type is a submit button; unchecked checkboxes send nothing; radio buttons are exclusive only when they share a name; files need POST plus enctype="multipart/form-data". Built-in validation (required, type="email", min, max, step, pattern) runs in the browser, so the server must validate again.

Exam angle: application questions show a short form and ask what gets submitted, or why a value is missing.

Attributes

Attributes add information to an element as name="value" pairs in the start tag. Global attributes work on every element: id (unique in the document), class (shared, space-separated), lang, title, hidden, tabindex and custom data-* attributes, which scripts read through element.dataset.

Boolean attributes such as disabled, checked, required and readonly are true when present, whatever their value. So disabled="false" still disables the control; remove the attribute instead.

Void elements such as <br>, <img>, <input> and <meta> have attributes but no content and no end tag.

Exam angle: boolean-attribute and duplicate-id questions catch many students who think like programmers rather than like parsers.

Accessibility

Accessibility means people using screen readers, keyboards or magnifiers can use the page. In HTML it starts with the right elements:

The first rule of ARIA (Accessible Rich Internet Applications) is to use a native element before adding ARIA roles. ARIA changes what assistive technology announces, but it adds no keyboard behaviour. Use aria-label when a control, such as an icon-only button, has no visible text.

Exam angle: analysis questions describe a user who cannot reach or understand a control and ask for the root cause.

Common traps

Worked examples

1. Understanding. Which element should hold a caption for an image placed inside <figure>? Answer: <figcaption>. It must be the first or last child of <figure>. <caption> is for tables, and <legend> is for fieldsets.

2. Application. A form uses method="get" with action="/jobs". It has a text field name="city" containing Multan and a select name="type" with remote chosen. What URL is requested? Answer: /jobs?city=Multan&type=remote. GET appends named controls to the query string in document order.

3. Analysis. A "Show password" toggle is a <span> with a click handler. Keyboard users cannot use it, and screen readers say nothing useful. What is the best fix? Answer: replace it with <button type="button">, give it a clear name such as "Show password", and reflect its state with aria-pressed. Adding tabindex alone would make the span focusable, but it still would not respond to Enter or Space or announce itself as a button.

Practise

The quiz below has 99 HTML Fundamentals questions, filterable by tier and difficulty.

Practise: 99 questions

Interactive quiz loading. The first 10 questions are shown below.

  1. What does <!DOCTYPE html> at the top of a page do?

    1. It is the root element that wraps the whole page
    2. It makes the browser render the page in standards (no-quirks) mode
    3. It declares the HTML 4.01 Strict document type definition
    4. It links the page to its CSS file
    Show answer

    Answer: B. It makes the browser render the page in standards (no-quirks) mode

    In current HTML the doctype is a required preamble whose only job is to stop browsers using quirks mode, the legacy rendering mode for very old pages. The root element is <html>, and no DTD is referenced any more.

  2. Which element represents the dominant content of a page's body and should not be repeated as a visible element?

    1. <section>
    2. <main>
    3. <article>
    4. <div>
    Show answer

    Answer: B. <main>

    <main> holds the content unique to the page, excluding repeated headers, navigation and footers. The HTML Standard allows only one visible (not hidden) <main> per document. <section> and <article> can appear many times, and <div> has no meaning.

  3. Which attribute provides a text alternative for an <img>?

    1. title
    2. src
    3. name
    4. alt
    Show answer

    Answer: D. alt

    alt gives the text that replaces the image for screen-reader users, when images fail to load and for search engines. title is only advisory tooltip text, src is the image URL, and name is not a valid attribute on <img> in current HTML.

  4. Which of these is a void element, one that has no content and no end tag?

    1. <br>
    2. <p>
    3. <span>
    4. <textarea>
    Show answer

    Answer: A. <br>

    Void elements such as br, img, input, meta, link and hr cannot have content, so they never take an end tag. <p>, <span> and <textarea> all hold content between start and end tags.

  5. A blog post that would still make sense if syndicated on its own, with its own heading and author, should be wrapped in which element?

    1. <aside>
    2. <nav>
    3. <header>
    4. <article>
    Show answer

    Answer: D. <article>

    <article> represents a self-contained composition that could be distributed independently, such as a post, news story or comment. <aside> is tangential content, <nav> holds major navigation links and <header> is introductory content.

  6. A <button> inside a <form> has no type attribute. What is its type?

    1. submit
    2. button
    3. reset
    4. none
    Show answer

    Answer: A. submit

    The default type of a button is submit, so clicking it submits its form. You must write type="button" for a button that only runs JavaScript, and type="reset" to restore default values.

  7. Which is a valid way to store custom data on an element for scripts to read?

    1. user-id="42"
    2. x-user-id="42"
    3. data-user-id="42"
    4. custom:user-id="42"
    Show answer

    Answer: C. data-user-id="42"

    Custom data attributes must start with data- and can be read in JavaScript through element.dataset (here dataset.userId). Invented attributes without the data- prefix are not conforming HTML.

  8. Which statement about the id and class attributes is correct?

    1. An id must be unique within the document; a class can be shared by many elements
    2. Both id and class must be unique in the document
    3. A class must be unique; an id can be repeated
    4. An element can have several ids separated by spaces
    Show answer

    Answer: A. An id must be unique within the document; a class can be shared by many elements

    id is a unique identifier, used by fragment links, label for and getElementById. class is a space-separated list of names that any number of elements may share, mainly for CSS and scripting.

  9. How does <label for="email"> connect to a form control?

    1. It is associated with the control whose name is email
    2. It is associated with the control whose id is email
    3. It is associated with the next input in the document, whatever its id
    4. It sets the input's type to email
    Show answer

    Answer: B. It is associated with the control whose id is email

    The for attribute holds the id of a labelable element. The association gives the control an accessible name, and clicking the label focuses or toggles the control. The name attribute is only used for form submission.

  10. What does <meta charset="utf-8"> do?

    1. Declares the character encoding the document uses
    2. Sets the language of the page for screen readers
    3. Tells search engines which keywords the page targets
    4. Makes the page responsive on mobile devices
    Show answer

    Answer: A. Declares the character encoding the document uses

    It tells the browser how to decode the bytes of the page into characters. It must appear within the first 1,024 bytes of the document, and UTF-8 is the only encoding the HTML Standard allows for new documents. Language is set with lang and responsiveness with the viewport meta tag.

FAQs

What is the difference between HTML5 and the HTML Living Standard?

HTML5 was a W3C snapshot published in 2014. Since then WHATWG has kept HTML as a continuously updated "living standard", and since 2019 the W3C has worked with it rather than publishing its own versions. In practice, "HTML5" now just means modern HTML, and the living standard is the current reference.

Are the b and i tags deprecated?

No. Both are conforming in current HTML, but with specific meanings. <b> draws attention to text without adding importance, such as keywords, and <i> marks an alternative voice, such as a technical term or a foreign word. For importance use <strong>, and for stress emphasis use <em>.

Does HTML validation make my form secure?

No. Attributes such as required and pattern run in the browser and improve the user experience, but users can edit the page or send requests directly. The server must always validate and sanitise input; this matters again in the Web Security topic later in the area.

Should I use a div or a section?

Use <section> when the content forms a themed part of the document that would naturally have a heading. Use <div> when you only need a wrapper for styling or scripting. If the content makes sense on its own, such as a blog post or a product card, <article> fits better.

Next step

Continue with CSS Fundamentals MCQs, go back to the Web Development MCQ hub, or test yourself across every area in an NSCT mock test.