HTML Basics: 246 MCQs with answers

Showing 200 of 246 multiple-choice questions from this kit.

Warm-up · 123 questions

Q1. What is the very first line in every HTML5 document?

Beginner
A `<body>` B `<html>` C `<head>` D `<!DOCTYPE html>`
Show answer & explanation

`<!DOCTYPE html>`

The `` declaration must be the very first line to tell the browser this is an HTML5 document and prevent quirks mode.

Q2. Which element is the root container that wraps all other HTML content?

Beginner
A `<html>` B `<head>` C `<body>` D `<!DOCTYPE html>`
Show answer & explanation

`<html>`

The `` element is the root container that wraps all content in an HTML document.

Q3. Which of the following is NOT typically placed inside the `<head>` section?

Beginner
A `<link rel="stylesheet" href="style.css">` B `<title>` C `<h1>` D `<meta charset="UTF-8">`
Show answer & explanation

`<h1>`

The `` tag is a visible heading element that belongs in the ``, not in the ``.

Q4. What is the main consequence of forgetting the `<!DOCTYPE html>` declaration?

Beginner
A The page will not load at all. B The page will load faster. C The browser may render the page in quirks mode, breaking layouts. D The `<title>` tag will be ignored.
Show answer & explanation

The browser may render the page in quirks mode, breaking layouts.

A missing `` can cause browsers to fall back to quirks mode, where CSS behaves unpredictably and layouts may break.

Q5. Why are CSS stylesheets linked inside the `<head>` rather than the `<body>`?

Beginner
A To prevent a flash of unstyled content (FOUC). B To make the HTML file smaller. C To allow the browser to ignore CSS. D To improve JavaScript performance.
Show answer & explanation

To prevent a flash of unstyled content (FOUC).

Linking CSS in the `` allows the browser to start styling the page immediately, preventing a flash of unstyled content.

Q6. A developer places a `<script>` tag inside the `<head>` that loads a large JavaScript file. What is the most likely negative effect?

Beginner
A The page will render faster. B The JavaScript will not execute. C The CSS will stop working. D The page content may be delayed from rendering while the script loads.
Show answer & explanation

The page content may be delayed from rendering while the script loads.

Placing large `` tags in the `` blocks rendering of the `` content until the script is downloaded and executed, delaying visible content.

Q7. Which attribute on the `<html>` tag improves accessibility by specifying the language of the page?

Beginner
A `class` B `style` C `lang` D `id`
Show answer & explanation

`lang`

The `lang` attribute (e.g., `lang="en"`) tells screen readers and search engines the language of the page, improving accessibility and SEO.

Q8. A student writes an HTML file with the following structure: `<!DOCTYPE html><html><body><head><title>Test</title></head></body></html>`. What is the main structural error?

Beginner
A The `<head>` is placed inside the `<body>`, which is incorrect. B The `<title>` tag is missing. C The `<html>` tag is missing the `lang` attribute. D The `<!DOCTYPE html>` is missing.
Show answer & explanation

The `<head>` is placed inside the `<body>`, which is incorrect.

The `` and `` are siblings, both nested directly inside ``. Placing `` inside `` is structurally invalid.

Q9. The `<!DOCTYPE html>` declaration is an HTML tag.

Beginner
A True B False
Show answer & explanation

False

The `` declaration is not an HTML tag; it is an instruction to the browser about the HTML version.

Q10. The `<head>` and `<body>` elements are siblings, both nested directly inside the `<html>` element.

Beginner
A True B False
Show answer & explanation

True

This is correct. They are at the same level within the `` root element.

Q11. Placing `<link>` tags for CSS in the `<body>` is a best practice for performance.

Beginner
A True B False
Show answer & explanation

False

CSS `` tags should be placed in the `` to prevent a flash of unstyled content; placing them in the `` is not a best practice.

Q12. A valid HTML document can have multiple `<body>` elements.

Beginner
A True B False
Show answer & explanation

False

A valid HTML document must contain exactly one `` element.

Q13. The ___ declaration must be the very first line in every HTML5 document to prevent quirks mode.

Beginner
Show answer & explanation

—

The `` declaration is required as the first line to tell the browser the document uses HTML5.

Q14. The ___ element is the root container that wraps all other HTML content.

Beginner
Show answer & explanation

—

The `` element is the root container for the entire HTML document.

Q15. The ___ section contains metadata such as the title and links to CSS files.

Beginner
Show answer & explanation

—

The `` section holds metadata that is not directly visible on the page.

Q16. The ___ attribute on the `<html>` tag specifies the language of the page, improving accessibility.

Beginner
Show answer & explanation

—

The `lang` attribute (e.g., `lang="en"`) helps screen readers and search engines understand the page language.

Q17. What is the purpose of the `<!DOCTYPE html>` declaration?

Beginner
Show answer & explanation

—

This is a foundational concept; the declaration is an instruction, not a tag.

Q18. Name the four main structural components of an HTML document in order.

Beginner
Show answer & explanation

—

These are the essential parts of the HTML skeleton.

Q19. What is the role of the `<html>` element?

Beginner
Show answer & explanation

—

Everything else is nested inside this element.

Q20. What type of information is stored in the `<head>` section?

Beginner
Show answer & explanation

—

The `` is for information about the page, not visible content.

Q21. What is the function of the `<body>` element?

Beginner
Show answer & explanation

—

The `` is where all visible elements go.

Q22. What does the `<meta charset="UTF-8">` tag do?

Beginner
Show answer & explanation

—

UTF-8 is the standard encoding for web pages.

Q23. How many `<html>`, `<head>`, and `<body>` elements should a valid HTML document have?

Beginner
Show answer & explanation

—

These are unique structural elements that cannot be repeated.

Q24. What is the relationship between the `<head>` and `<body>` elements?

Beginner
Show answer & explanation

—

They are at the same level within the root element.

Q25. Which of the following is the correct way to write a closing tag for a paragraph?

Beginner
A `<p />` B `</p>` C `<\p>` D `<p>`
Show answer & explanation

`</p>`

A closing tag has a forward slash before the tag name: ``. The other options are either an opening tag, a self-closing variant, or incorrect syntax.

Q26. What is the main difference between an opening tag and a closing tag?

Beginner
A The closing tag has an asterisk after the tag name. B The closing tag is written in uppercase. C The closing tag has a forward slash before the tag name. D The closing tag has an exclamation mark.
Show answer & explanation

The closing tag has a forward slash before the tag name.

The closing tag is identical to the opening tag except it includes a forward slash (`/`) right before the tag name, like ``.

Q27. Which of the following is a self-closing tag?

Beginner
A `<h1>` B `<br>` C `<li>` D `<p>`
Show answer & explanation

`<br>`

`` is a self-closing (void) element that creates a line break. The others require closing tags because they wrap content.

Q28. What does semantic HTML primarily improve?

Beginner
A Font styling B Page loading speed C Accessibility, SEO, and code readability D Image quality
Show answer & explanation

Accessibility, SEO, and code readability

Semantic HTML uses meaningful tags that help screen readers, search engines, and developers understand the structure and purpose of content.

Q29. What is the correct nesting order for an unordered list with two items?

Beginner
A `<ul><li>Item 1</li><li>Item 2</li></ul>` B `<li><ul>Item 1</ul></li>` C `<li><ul>Item 1</li><li>Item 2</li></ul>` D `<ul><li>Item 1<li>Item 2</ul>`
Show answer & explanation

`<ul><li>Item 1</li><li>Item 2</li></ul>`

The `` element contains `` elements. Each `` must have its own closing tag. Option B shows the correct nesting pattern.

Q30. Which tag should you use to mark up a navigation menu for better accessibility?

Beginner
A `<header>` B `<nav>` C `<span>` D `<div>`
Show answer & explanation

`<nav>`

`` is the semantic tag specifically designed for navigation menus. Using `` would work visually but lacks semantic meaning.

Q31. What happens if you write `<p>Hello` without a closing tag?

Beginner
A The browser shows an error and stops rendering. B The browser treats everything after as part of that paragraph until it finds a closing tag or the end of the document. C The browser ignores the tag and displays plain text. D The browser automatically adds a closing tag at the end of the line.
Show answer & explanation

The browser treats everything after as part of that paragraph until it finds a closing tag or the end of the document.

Browsers are forgiving with HTML errors. If a closing tag is missing, the browser will often continue the element until it encounters another opening tag or the document ends, causing unexpected layout issues.

Q32. Why is using `<strong>` preferred over `<b>` in modern HTML?

Beginner
A `<strong>` is faster to render. B `<strong>` has semantic meaning (importance), while `<b>` is purely stylistic. C `<strong>` automatically adds a line break. D `<strong>` works in all browsers, but `<b>` does not.
Show answer & explanation

`<strong>` has semantic meaning (importance), while `<b>` is purely stylistic.

`` conveys that the content is important (semantic), whereas `` only makes text bold without additional meaning. Modern HTML favors semantic tags for accessibility and SEO.

Q33. All HTML tags require a closing tag.

Beginner
A True B False
Show answer & explanation

False

Self-closing tags (void elements) like `` and `` do not have a closing tag because they don't wrap content.

Q34. HTML tag names are case-insensitive, but lowercase is the convention.

Beginner
A True B False
Show answer & explanation

True

While HTML doesn't require lowercase, using lowercase (e.g., `` not ``) is the standard convention for consistency and readability.

Q35. Using semantic HTML tags can improve a website's search engine ranking.

Beginner
A True B False
Show answer & explanation

True

Semantic tags help search engines understand the structure and importance of content, which can positively impact SEO.

Q36. The `<img>` tag requires a closing `</img>` tag.

Beginner
A True B False
Show answer & explanation

False

`` is a self-closing (void) element. It does not have a closing tag. The image source is specified using attributes like `src`.

Q37. An HTML ___ consists of an opening tag, content, and a closing tag.

Beginner
Show answer & explanation

—

The term 'element' refers to the complete structure: opening tag + content + closing tag. A 'tag' alone is just the markup.

Q38. The ___ tag is used to create a hyperlink to another webpage.

Beginner
Show answer & explanation

—

The `` (anchor) tag creates hyperlinks. It requires an `href` attribute to specify the destination URL.

Q39. Placing one HTML element inside another is called ___.

Beginner
Show answer & explanation

—

Nesting creates a parent-child relationship between elements, which browsers use to understand the document hierarchy.

Q40. The `<h1>` to `<h6>` tags define headings with ___ importance as the number increases.

Beginner
Show answer & explanation

—

`` is the most important (top-level) heading, and `` is the least important. The importance decreases as the number goes up.

Q41. What is an HTML tag?

Beginner
Show answer & explanation

—

This is the foundational definition. The answer should mention angle brackets and the pair structure.

Q42. What is the difference between an opening tag and a closing tag?

Beginner
Show answer & explanation

—

The key point is the forward slash in the closing tag.

Q43. What is an HTML element?

Beginner
Show answer & explanation

—

The answer should clarify that an element is more than just a tag — it includes the content and closing tag.

Q44. What is a self-closing tag? Give two examples.

Beginner
Show answer & explanation

—

The answer should explain that these tags are 'empty' and provide at least two correct examples.

Q45. What does the `<p>` tag do?

Beginner
Show answer & explanation

—

The answer should mention that it's for paragraphs and is a block-level element.

Q46. What do the `<h1>` to `<h6>` tags represent?

Beginner
Show answer & explanation

—

The answer should explain the hierarchy and that importance decreases as the number increases.

Q47. What is the purpose of the `<a>` tag?

Beginner
Show answer & explanation

—

The answer should mention hyperlinks and the `href` attribute.

Q48. What is the purpose of the `<img>` tag?

Beginner
Show answer & explanation

—

The answer should mention embedding images, self-closing nature, and the `src` attribute.

Q49. What do `<ul>` and `<ol>` tags create?

Beginner
Show answer & explanation

—

The answer should distinguish between unordered and ordered lists and mention ``.

Q50. What is the convention for writing tag names in HTML?

Beginner
Show answer & explanation

—

The answer should mention both the convention (lowercase) and the rule (case-insensitive).

Q51. What does HTML stand for?

Beginner
A Home Tool Markup Language B High Tech Modern Language C HyperTransfer Markup Language D HyperText Markup Language
Show answer & explanation

HyperText Markup Language

HTML stands for HyperText Markup Language. 'HyperText' refers to linked documents, and 'Markup' means using tags to annotate content.

Q52. Which of the following is a self-closing HTML tag?

Beginner
A `<h1>` B `<p>` C `<div>` D `<img>`
Show answer & explanation

`<img>`

`` is self-closing; it does not require a separate closing tag. Tags like ``, ``, and `` need a closing tag.

Q53. Why is HTML not considered a programming language?

Beginner
A It cannot be used to create web pages. B It requires a compiler to run. C It does not support variables, loops, or conditional logic. D It is only used for styling.
Show answer & explanation

It does not support variables, loops, or conditional logic.

HTML is a markup language, not a programming language. It lacks programming constructs like variables, loops, and conditionals. It is declarative, describing content structure.

Q54. What is the purpose of the `alt` attribute on an `<img>` tag?

Beginner
A To link the image to another page B To add a border to the image C To specify the image height D To provide alternative text for accessibility and SEO
Show answer & explanation

To provide alternative text for accessibility and SEO

The `alt` attribute provides a text description of the image. It is used by screen readers for accessibility and by search engines for indexing.

Q55. Which HTML element wraps the entire document?

Beginner
A `<document>` B `<body>` C `<html>` D `<head>`
Show answer & explanation

`<html>`

The `` element is the root element that wraps all content on the page. It contains `` and `` as child elements.

Q56. What is semantic HTML?

Beginner
A Using HTML tags that convey the meaning of content B Using HTML tags that only affect appearance C Using HTML tags that are self-closing D Using HTML tags that contain JavaScript
Show answer & explanation

Using HTML tags that convey the meaning of content

Semantic HTML uses tags that describe the meaning of the content (e.g., ``, ``, ``). This improves accessibility and SEO.

Q57. Which of the following is a valid HTML element with an attribute?

Beginner
A `<img src='photo.jpg'>` B `<img source='photo.jpg'>` C `<img href='photo.jpg'>` D `<image src='photo.jpg'>`
Show answer & explanation

`<img src='photo.jpg'>`

The correct tag for an image is ``, and the attribute for the file path is `src`. The `href` attribute is used for links (``).

Q58. What is the main advantage of separating HTML structure from CSS presentation?

Beginner
A It makes HTML a programming language. B It allows the same HTML to be styled differently for different devices. C It eliminates the need for JavaScript. D It makes the HTML file larger.
Show answer & explanation

It allows the same HTML to be styled differently for different devices.

Separation of concerns allows the same HTML content to be presented in different ways (e.g., desktop vs. mobile) by swapping CSS files, improving maintainability and accessibility.

Q59. HTML is a programming language that can perform calculations.

Beginner
A True B False
Show answer & explanation

False

HTML is a markup language, not a programming language. It cannot perform logic or calculations.

Q60. The `<head>` element contains the visible content of a web page.

Beginner
A True B False
Show answer & explanation

False

The `` element contains metadata (like the title and links to stylesheets), not visible content. The visible content goes in the `` element.

Q61. Using semantic HTML tags can improve a website's search engine ranking.

Beginner
A True B False
Show answer & explanation

True

Search engines use HTML structure to index content. Semantic tags like ``, ``, and `` help search engines understand the page's content and rank it appropriately.

Q62. The `<br>` tag requires a closing tag like `</br>`.

Beginner
A True B False
Show answer & explanation

False

`` is a self-closing tag and does not need a separate closing tag. It is used to insert a line break.

Q63. HTML uses ___ to annotate text and define the structure of a web page.

Beginner
Show answer & explanation

—

Tags are the core of HTML. They are keywords enclosed in angle brackets (e.g., ``, ``) that tell the browser how to structure content.

Q64. The ___ attribute on an `<img>` tag provides a text description for accessibility and SEO.

Beginner
Show answer & explanation

—

The `alt` attribute provides alternative text that screen readers read aloud and search engines use to understand the image content.

Q65. The hierarchical structure of an HTML document is called the ___.

Beginner
Show answer & explanation

—

The DOM is a tree-like representation of the HTML document that browsers and JavaScript use to interact with the page.

Q66. Modern best practice separates HTML for structure and ___ for presentation.

Beginner
Show answer & explanation

—

CSS (Cascading Style Sheets) handles colors, fonts, layout, and other visual aspects, while HTML focuses on content structure.

Q67. What does HTML stand for?

Beginner
Show answer & explanation

—

Full marks for stating the full form correctly.

Q68. Is HTML a programming language? Explain briefly.

Beginner
Show answer & explanation

—

Full marks for stating it is not a programming language and giving a reason (no logic/calculations).

Q69. What is the difference between an opening tag and a closing tag?

Beginner
Show answer & explanation

—

Full marks for describing both tags and noting the forward slash in the closing tag.

Q70. Give two examples of self-closing HTML tags.

Beginner
Show answer & explanation

—

Full marks for naming two correct self-closing tags (e.g., ``, ``, ``, ``).

Q71. What is the purpose of the `alt` attribute on an `<img>` tag?

Beginner
Show answer & explanation

—

Full marks for mentioning both accessibility and SEO benefits.

Q72. What are the two main sections inside an `<html>` element?

Beginner
Show answer & explanation

—

Full marks for naming both `` and `` with brief descriptions.

Q73. What does the `<a>` tag do?

Beginner
Show answer & explanation

—

Full marks for stating it creates a link.

Q74. What is the purpose of the `<head>` element?

Beginner
Show answer & explanation

—

Full marks for mentioning metadata and that it is not visible on the page.

Q75. What does the term 'HyperText' in HTML refer to?

Beginner
Show answer & explanation

—

Full marks for explaining linking between documents.

Q76. Which HTML tag is used for the most important heading?

Beginner
A `<heading>` B `<h6>` C `<h1>` D `<head>`
Show answer & explanation

`<h1>`

`` is the most important heading tag, used for the main title of the page. `` is the least important, and `` and `` are not valid heading tags.

Q77. What does the `<p>` tag define?

Beginner
A A hyperlink B A page title C An image D A paragraph of text
Show answer & explanation

A paragraph of text

The `` tag defines a paragraph, a block-level element for text content. Page titles use ``, hyperlinks use ``, and images use ``.

Q78. How many `<h1>` tags are recommended per web page?

Beginner
A As many as needed B At least two C Exactly one D None, use `<h2>` instead
Show answer & explanation

Exactly one

Best practice is to use exactly one `` per page to clearly indicate the main topic. Multiple `` tags can confuse search engines and screen readers.

Q79. Why is it important not to skip heading levels (e.g., going from `<h1>` to `<h4>`)?

Beginner
A It is not allowed by HTML standards B It makes the page load slower C It causes the text to disappear D It breaks the logical hierarchy for screen readers
Show answer & explanation

It breaks the logical hierarchy for screen readers

Skipping heading levels disrupts the logical structure that screen readers rely on for navigation. While HTML allows it technically, it harms accessibility and user experience.

Q80. Which of the following is a correct use of headings and paragraphs?

Beginner
A `<h2>Section Title</h2><h3>Content here.</h3>` B `<h2>Section Title</h2><p>Content here.</p>` C `<p>Section Title</p><p>Content here.</p>` D `<p><h2>Section Title</h2>Content here.</p>`
Show answer & explanation

`<h2>Section Title</h2><p>Content here.</p>`

The correct structure uses a heading tag (``) followed by a paragraph (``) as separate block-level elements. Nesting a heading inside a paragraph or using a heading for content is incorrect.

Q81. What is the primary role of headings in a web page?

Beginner
A To add decorative styling B To make text larger and bolder C To create hyperlinks D To provide structural hierarchy and meaning
Show answer & explanation

To provide structural hierarchy and meaning

Headings define the structural hierarchy of content, helping both users and assistive technologies understand the organization. Visual styling should be handled by CSS, not headings.

Q82. A student writes `<h1>Main Title</h1><h3>Subsection</h3>`. What is the issue?

Beginner
A There is no paragraph after the heading B The `<h3>` tag is misspelled C A heading level was skipped, breaking hierarchy D The `<h1>` tag should be `<h2>`
Show answer & explanation

A heading level was skipped, breaking hierarchy

Going from `` to `` skips ``, which breaks the logical heading hierarchy. This can confuse screen readers and reduce accessibility.

Q83. How do search engines primarily use heading tags?

Beginner
A To count the number of images B To determine the page's loading speed C To check for spelling errors D To understand the topic and structure of content
Show answer & explanation

To understand the topic and structure of content

Search engines analyze heading tags to grasp the main topics and subtopics of a page, which influences search rankings. They do not use headings for speed, images, or spelling.

Q84. The `<p>` tag automatically adds space before and after the paragraph.

Beginner
A True B False
Show answer & explanation

True

Browsers apply default margins to `` elements, creating visual spacing between paragraphs for readability.

Q85. You can use `<h1>` multiple times on a single page without any negative effects.

Beginner
A True B False
Show answer & explanation

False

While technically allowed, using multiple `` tags is not best practice as it dilutes the main topic and can confuse search engines and screen readers.

Q86. Headings should be used for their visual appearance, such as making text larger.

Beginner
A True B False
Show answer & explanation

False

Headings are for structural hierarchy, not visual styling. Use CSS for font size and appearance.

Q87. A well-structured page with headings and paragraphs improves both accessibility and SEO.

Beginner
A True B False
Show answer & explanation

True

Proper use of headings and paragraphs enhances readability for users, aids screen reader navigation, and helps search engines understand content, benefiting both accessibility and SEO.

Q88. HTML headings range from `<h1>` (most important) to `<h6>` (___ important).

Beginner
Show answer & explanation

—

`` is the least important heading in the hierarchy, used for the deepest level of subsections.

Q89. The ___ tag defines a paragraph in HTML.

Beginner
Show answer & explanation

—

The `` tag is used to define a paragraph, a block-level element for text content.

Q90. Skipping heading levels (e.g., from `<h1>` to `<h3>`) breaks the logical ___ for screen readers.

Beginner
Show answer & explanation

—

Screen readers rely on the heading hierarchy to navigate content; skipping levels disrupts this structure.

Q91. To change the visual size of a heading, you should use ___ instead of misusing heading tags.

Beginner
Show answer & explanation

—

CSS (Cascading Style Sheets) is used for styling, such as font size, while headings are reserved for structural meaning.

Q92. What are the HTML tags used for headings and what do they represent?

Beginner
Show answer & explanation

—

This is a foundational recall question about the heading tag range.

Q93. What does the `<p>` tag define and how do browsers display it by default?

Beginner
Show answer & explanation

—

Tests understanding of the paragraph tag and its default rendering.

Q94. How many `<h1>` tags should you use per page and why?

Beginner
Show answer & explanation

—

Reinforces the best practice of a single main heading.

Q95. Do paragraphs have a hierarchy like headings?

Beginner
Show answer & explanation

—

Highlights a key difference between headings and paragraphs.

Q96. What is the best practice for using multiple `<h2>` tags?

Beginner
Show answer & explanation

—

Reinforces that multiple `` tags are acceptable.

Q97. When would you use `<h4>` to `<h6>` tags?

Beginner
Show answer & explanation

—

Covers the usage of lower-level headings.

Q98. Do you need a heading before every paragraph?

Beginner
Show answer & explanation

—

Clarifies the relationship between headings and paragraphs.

Q99. What is the main purpose of using headings in a web page?

Beginner
Show answer & explanation

—

Tests the core purpose of headings.

Q100. Which HTML element is used to group input fields and control form submission?

Beginner
A `<div>` B `<fieldset>` C `<form>` D `<input>`
Show answer & explanation

`<form>`

The `` element is the container that groups input fields and handles submission. The `` tag is used for individual fields, not for grouping.

Q101. What attribute of the `<input>` tag determines the behavior and appearance of the input field?

Beginner
A `type` B `value` C `id` D `name`
Show answer & explanation

`type`

The `type` attribute (e.g., text, password, email) defines how the input looks and behaves. The `name` attribute identifies the data, but does not control appearance.

Q102. What happens if you forget to include the `name` attribute on an input field?

Beginner
A The input's value is ignored on submission. B The form will show an error. C The form will not submit. D The input field will not display.
Show answer & explanation

The input's value is ignored on submission.

Without a `name` attribute, the input's value is not included in the form data when submitted. The form still submits, but the server never receives that field's data.

Q103. Which input type creates a button that automatically submits the form?

Beginner
A `type="reset"` B `type="submit"` C `type="button"` D `type="image"`
Show answer & explanation

`type="submit"`

`` creates a button that submits the form. `type="button"` does nothing without JavaScript, and `type="reset"` clears the form.

Q104. A developer uses `<input type="button" value="Click">` expecting it to submit the form. What will happen?

Beginner
A The form is reset. B The form submits normally. C Nothing happens; the button does nothing without JavaScript. D The page reloads.
Show answer & explanation

Nothing happens; the button does nothing without JavaScript.

`type="button"` creates a generic button that does not submit the form. It requires JavaScript to add functionality. This is a common mistake.

Q105. Which input type provides basic email validation and shows a mobile-friendly keyboard?

Beginner
A `type="password"` B `type="text"` C `type="url"` D `type="email"`
Show answer & explanation

`type="email"`

`type="email"` validates that the input looks like an email address and often brings up a keyboard with an '@' symbol on mobile devices.

Q106. What is the primary difference between `<input type="checkbox">` and `<input type="radio">`?

Beginner
A Checkboxes allow multiple selections; radio buttons allow only one. B Checkboxes are square; radio buttons are round. C Checkboxes submit data; radio buttons do not. D Radio buttons require a name attribute; checkboxes do not.
Show answer & explanation

Checkboxes allow multiple selections; radio buttons allow only one.

Checkboxes let users select multiple options, while radio buttons restrict selection to one option within a group. Both require a `name` attribute to submit data.

Q107. A student writes `<form><input type="text"></form>` and wonders why no data is sent. What is the most likely missing element?

Beginner
A A `name` attribute on the input B A submit button C An `action` attribute on the form D A `method` attribute on the form
Show answer & explanation

A submit button

Without a submit button (``), the user has no way to submit the form. While a `name` attribute is also needed for data to be sent, the immediate issue is the lack of a submission mechanism.

Q108. The `<form>` element is visible on the page by default.

Beginner
A True B False
Show answer & explanation

False

The `` element is an invisible container that groups inputs and controls submission. It does not have any visual appearance unless styled with CSS.

Q109. An input field without a `name` attribute will still send its value to the server on form submission.

Beginner
A True B False
Show answer & explanation

False

The `name` attribute is essential for the input's value to be included in the form data. Without it, the value is ignored on submission.

Q110. `<input type="number">` restricts input to numeric values and shows a numeric keypad on mobile devices.

Beginner
A True B False
Show answer & explanation

True

The `number` type limits input to numbers and provides a numeric keypad on mobile, making data entry easier.

Q111. Using `<input type="button">` will submit the form when clicked.

Beginner
A True B False
Show answer & explanation

False

`type="button"` creates a generic button that does not submit the form. It requires JavaScript to perform any action.

Q112. The ___ attribute of the `<input>` tag determines the kind of input field, such as text, password, or email.

Beginner
Show answer & explanation

—

The `type` attribute controls the behavior and appearance of the input field.

Q113. To create a password field that masks user input, use `<input type="___">`.

Beginner
Show answer & explanation

—

The `password` type hides the characters as the user types for security.

Q114. A form cannot be submitted without a(n) ___ element, such as `<input type="submit">`.

Beginner
Show answer & explanation

—

A submit button triggers the form submission. Without it, the user has no way to send the data.

Q115. If an input field lacks the ___ attribute, its value will not be sent to the server when the form is submitted.

Beginner
Show answer & explanation

—

The `name` attribute acts as a key for the input's value in the form data. Without it, the value is ignored.

Q116. What is the purpose of the `<form>` element in HTML?

Beginner
Show answer & explanation

—

It acts as a wrapper for inputs and defines how data is sent.

Q117. Name three common input types used in HTML forms.

Beginner
Show answer & explanation

—

Any three of these are acceptable.

Q118. Why is the `name` attribute important on an input field?

Beginner
Show answer & explanation

—

It labels the data for the server.

Q119. What does `<input type="password">` do differently from `<input type="text">`?

Beginner
Show answer & explanation

—

The password type hides the characters.

Q120. What is the purpose of `<input type="number">`?

Beginner
Show answer & explanation

—

It ensures only numbers are entered.

Q121. What does the `<form>` element look like on a webpage without CSS styling?

Beginner
Show answer & explanation

—

It is a container, not a visual element.

Q122. List two real-world examples of forms on websites.

Beginner
Show answer & explanation

—

Any two valid examples are acceptable.

Q123. What attribute must be added to an input field for its value to be sent to the server?

Beginner
Show answer & explanation

—

The name attribute identifies the data.

Building up · 57 questions

Q124. Why is the `<title>` tag important for SEO?

Intermediate
Show answer & explanation

—

It helps both users and search engines identify the page.

Q125. Where should CSS stylesheets be linked in an HTML document and why?

Intermediate
Show answer & explanation

—

This allows the browser to start styling the page immediately.

Q126. Why are `<script>` tags often placed at the end of the `<body>`?

Intermediate
Show answer & explanation

—

This prevents JavaScript from blocking the rendering of the page.

Q127. What is quirks mode and what causes it?

Intermediate
Show answer & explanation

—

It is an older, stricter mode that can break modern CSS layouts.

Q128. What does the `lang` attribute on the `<html>` tag do?

Intermediate
Show answer & explanation

—

For example, `` indicates English.

Q129. What happens if you place `<title>` or `<link>` tags inside the `<body>`?

Intermediate
Show answer & explanation

—

These tags belong in the `` section.

Q130. In what order does a browser process an HTML document?

Intermediate
Show answer & explanation

—

This order affects performance and resource loading.

Q131. A developer writes the following HTML snippet: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>My Page</title> </head> <body> <h1>Welcome</h1> <p>This is a paragraph.</p> </body> </html> ``` If the developer removes the `<!DOCTYPE html>` declaration, what is the most likely consequence?

Intermediate
A The `<title>` tag will no longer appear on the browser tab. B The `lang` attribute will become invalid. C The browser may enter quirks mode, causing unpredictable CSS rendering. D The page will not load at all.
Show answer & explanation

The browser may enter quirks mode, causing unpredictable CSS rendering.

Without ``, browsers may fall back to quirks mode, an older rendering mode that can break CSS layouts. The page still loads, but styling may be inconsistent. The `` and `lang` attribute remain functional.

Q132. Consider the following HTML document structure: ```html <!DOCTYPE html> <html> <body> <head> <title>Test</title> </head> <p>Content</p> </body> </html> ``` What is the primary structural error in this document?

Intermediate
A The `<head>` element is incorrectly placed inside the `<body>` element. B The `<p>` tag should be inside a `<div>` element. C The `<title>` tag is missing a closing slash. D The `lang` attribute is missing from the `<html>` tag.
Show answer & explanation

The `<head>` element is incorrectly placed inside the `<body>` element.

In a valid HTML document, `` and `` are siblings nested directly inside ``. Here, `` is placed inside ``, which violates the standard structure. The `` tag is correctly self-closing, the `lang` attribute is optional, and `` can be a direct child of ``.

Q133. A developer wants to improve the performance of a webpage that includes a large JavaScript file. Where should the `<script>` tag be placed, and why?

Intermediate
A Immediately after the `<!DOCTYPE html>` declaration, to ensure the script runs first. B Inside the `<html>` tag but outside `<head>` and `<body>`, to avoid blocking rendering. C Inside the `<head>` section, because JavaScript should load before the page content. D At the end of the `<body>` section, so the page content renders before the script downloads and executes.
Show answer & explanation

At the end of the `<body>` section, so the page content renders before the script downloads and executes.

Placing `` at the end of `` is a best practice because the browser processes HTML top-to-bottom. This allows the visible content to load first, preventing a blank screen while the JavaScript downloads. Inside ``, a large script would block rendering until it finishes.

Q134. Which of the following statements best explains the relationship between the `<head>` and `<body>` elements in a valid HTML5 document?

Intermediate
A The `<body>` element is a child of the `<head>` element. B The `<head>` element is a child of the `<body>` element. C The `<head>` and `<body>` elements are siblings, both nested directly inside the `<html>` element. D The `<head>` element comes after the `<body>` element in the document order.
Show answer & explanation

The `<head>` and `<body>` elements are siblings, both nested directly inside the `<html>` element.

In the standard HTML document structure, `` and `` are sibling elements, both directly inside the root `` element. The `` contains metadata and appears before ``, which holds visible content. They are not nested within each other.

Q135. A developer notices that their webpage displays a flash of unstyled content (FOUC) when loading. Which of the following is the most likely cause related to document structure?

Intermediate
A The `<title>` tag is placed inside the `<body>` section. B The `<link>` tag for the CSS stylesheet is placed inside the `<body>` section instead of the `<head>`. C The `<!DOCTYPE html>` declaration is missing. D The `lang` attribute on the `<html>` tag is set to an incorrect value.
Show answer & explanation

The `<link>` tag for the CSS stylesheet is placed inside the `<body>` section instead of the `<head>`.

Placing `` for CSS in the `` allows the browser to load styles before rendering the ``. If the `` is in the ``, the browser may start rendering content without styles, causing a flash of unstyled content (FOUC). Missing `` causes quirks mode, not FOUC; `` placement affects the tab title, not styling; and `lang` affects…

Q136. What is nesting in HTML?

Intermediate
Show answer & explanation

—

The answer should explain the parent-child relationship and give a concrete example.

Q137. What is semantic HTML?

Intermediate
Show answer & explanation

—

The answer should define semantic HTML and mention its benefits.

Q138. Why is semantic HTML important for accessibility?

Intermediate
Show answer & explanation

—

The answer should connect semantic tags to assistive technology use.

Q139. What happens if you forget a closing tag in HTML?

Intermediate
Show answer & explanation

—

The answer should explain the practical consequence, not just that it's 'wrong'.

Q140. What is the tree structure of HTML elements?

Intermediate
Show answer & explanation

—

The answer should mention the DOM tree and parent-child relationships.

Q141. Consider the following HTML snippet: ```html <article> <h2>Title</h2> <p>Content <strong>important</strong> text.</p> </article> ``` Which statement best explains the relationship between the `<strong>` element and the `<p>` element?

Intermediate
A The `<strong>` element is a descendant of the `<article>` element but not of the `<p>` element. B The `<strong>` element is a child of the `<p>` element, and the `<p>` element is a child of the `<article>` element. C The `<strong>` element is a parent of the `<p>` element because it contains the text 'important'. D The `<strong>` element is a sibling of the `<p>` element because they are at the same nesting level.
Show answer & explanation

The `<strong>` element is a child of the `<p>` element, and the `<p>` element is a child of the `<article>` element.

In the nested structure, `` is inside ``, so it is a child of ``. The `` itself is inside ``, making it a child of ``. The correct option accurately describes this parent-child chain.

Q142. Which of the following best explains why using `<nav>` for a navigation menu is preferred over using a generic `<div>` with a class like `class="nav"`?

Intermediate
A The `<nav>` tag automatically applies CSS styles that make the menu look better than a `<div>`. B The `<nav>` tag is required for the menu to be clickable, while a `<div>` cannot contain links. C The `<nav>` tag is a self-closing tag, so it reduces the amount of code needed. D The `<nav>` tag provides semantic meaning that helps screen readers identify the navigation region, improving accessibility.
Show answer & explanation

The `<nav>` tag provides semantic meaning that helps screen readers identify the navigation region, improving accessibility.

Semantic HTML tags like `` convey meaning about the content they wrap. Screen readers and other assistive technologies can use this information to help users navigate the page, which is a key accessibility benefit. A `` has no semantic meaning.

Q143. An HTML document contains the following code: ```html <p>First paragraph <p>Second paragraph</p> ``` What is the most likely outcome when a browser renders this code?

Intermediate
A The browser will treat the text 'First paragraph' as a paragraph, and then treat 'Second paragraph' as a separate paragraph, but the first paragraph may incorrectly include subsequent content. B The browser will display an error because the first `<p>` tag is missing its closing tag. C The browser will ignore the missing closing tag and display both lines as a single paragraph. D The browser will automatically close the first `<p>` tag before the second `<p>` tag, so both paragraphs display correctly.
Show answer & explanation

The browser will treat the text 'First paragraph' as a paragraph, and then treat 'Second paragraph' as a separate paragraph, but the first paragraph may incorrectly include subsequent content.

Browsers are forgiving with missing closing tags, but they may not close them exactly where intended. In this case, the first `` has no closing tag, so the browser might implicitly close it when it encounters the second ``, but the exact behavior can vary and may lead to unexpected nesting or styling issues. The correc…

Q144. Given the following HTML: ```html <ul> <li>Apples</li> <li>Bananas</li> </ul> ``` If a developer wants to add a third item 'Cherries' after 'Bananas', which of the following correctly demonstrates the proper nesting and tag usage?

Intermediate
A ```html <ul> <li>Apples</li> <li>Bananas</li> <li>Cherries</li> </li> ``` B ```html <ul> <li>Apples</li> <li>Bananas</li> <li>Cherries</li> </ul> ``` (Note: This is identical to the first option, but with an extra space before `<ul>`) C ```html <ul> <li>Apples</li> <li>Bananas</li> <li>Cherries</li> </ul> ``` D ```html <ul> <li>Apples</li> <li>Bananas</li> <li>Cherries</ul> ```
Show answer & explanation

```html <ul> <li>Apples</li> <li>Bananas</li> <li>Cherries</li> </ul> ```

The correct structure is to add a new `` element inside the ``, and the `` must have a proper closing tag ``. The first option shows exactly that. The second option has an extra `` that doesn't match any opening tag. The third option incorrectly closes the `` inside the last ``. The fourth option is a duplicate of the…

Q145. Which of the following statements correctly compares the `<b>` tag and the `<strong>` tag in modern HTML?

Intermediate
A Both tags are identical in meaning and should be used interchangeably. B The `<strong>` tag conveys semantic importance, whereas `<b>` is a presentational tag with no semantic meaning. C The `<b>` tag is semantic and indicates importance, while `<strong>` is purely presentational. D The `<b>` tag is a self-closing tag, while `<strong>` requires a closing tag.
Show answer & explanation

The `<strong>` tag conveys semantic importance, whereas `<b>` is a presentational tag with no semantic meaning.

In modern HTML, `` indicates that its content has strong importance, which is semantic. The `` tag is a presentational element that only makes text bold without adding meaning. Therefore, `` is preferred for accessibility and SEO.

Q146. What is the Document Object Model (DOM)?

Intermediate
Show answer & explanation

—

Full marks for describing it as a tree structure and mentioning its use by browsers/scripts.

Q147. What is semantic HTML?

Intermediate
Show answer & explanation

—

Full marks for explaining that tags describe meaning, not just appearance.

Q148. Why should you avoid using `<font>` or `<center>` tags in modern HTML?

Intermediate
Show answer & explanation

—

Full marks for mentioning separation of concerns and CSS.

Q149. How does HTML help with web accessibility?

Intermediate
Show answer & explanation

—

Full marks for mentioning semantic tags and assistive technologies.

Q150. What is the difference between HTML and CSS?

Intermediate
Show answer & explanation

—

Full marks for clearly distinguishing structure (HTML) from presentation (CSS).

Q151. Name three places where HTML is used besides web pages.

Intermediate
Show answer & explanation

—

Full marks for listing three valid uses (e.g., email, mobile apps, e-books, documents).

Q152. Given the following HTML snippet: ```html <ul> <li>Item A</li> <li>Item B</li> </ul> ``` Which statement best describes the relationship between the `<ul>` and `<li>` elements?

Intermediate
A The `<ul>` and `<li>` elements are both self-closing tags. B The `<li>` elements are nested inside the `<ul>`, making them child nodes of the `<ul>` in the DOM. C The `<ul>` and `<li>` elements are siblings in the DOM tree. D The `<ul>` is a child of each `<li>` element.
Show answer & explanation

The `<li>` elements are nested inside the `<ul>`, making them child nodes of the `<ul>` in the DOM.

In HTML, nesting creates a parent-child relationship. The `` is the parent element, and each `` is a child element nested inside it. This hierarchical structure is reflected in the Document Object Model (DOM).

Q153. Why is HTML considered a **markup language** rather than a **programming language**?

Intermediate
A HTML can perform arithmetic calculations using tags like `<math>`. B HTML uses tags to annotate and describe the structure of content, but it lacks logic constructs like loops and conditionals. C HTML supports variables and functions, similar to JavaScript. D HTML is compiled into machine code before being displayed in a browser.
Show answer & explanation

HTML uses tags to annotate and describe the structure of content, but it lacks logic constructs like loops and conditionals.

HTML is purely declarative: it marks up content to define its meaning (e.g., headings, paragraphs). It does not include programming constructs such as variables, loops, or conditionals, which are essential for a language to be considered a programming language.

Q154. A developer writes the following HTML: ```html <img src="logo.png" alt="Company Logo"> ``` Which of the following best explains the role of the `alt` attribute in terms of accessibility and SEO?

Intermediate
A The `alt` attribute is used to resize the image on the page. B The `alt` attribute provides a text alternative for screen readers and helps search engines understand the image content. C The `alt` attribute controls the border color of the image. D The `alt` attribute is optional and has no impact on accessibility or SEO.
Show answer & explanation

The `alt` attribute provides a text alternative for screen readers and helps search engines understand the image content.

The `alt` attribute supplies a textual description of an image. Screen readers use it to convey the image's content to visually impaired users, and search engines rely on it to index the image properly, improving both accessibility and SEO.

Q155. Compare the following two approaches for creating a heading on a web page: - Approach A: `<h1>Welcome</h1>` - Approach B: `<div style="font-size: 32px; font-weight: bold;">Welcome</div>` Which statement correctly explains the advantage of Approach A?

Intermediate
A Approach A is the only way to create a heading that is centered on the page. B Approach A uses semantic HTML, which improves accessibility for screen readers and helps search engines understand the page structure. C Approach B is invalid HTML because `<div>` cannot contain text. D Approach A is more concise and always displays the heading in a larger font than Approach B.
Show answer & explanation

Approach A uses semantic HTML, which improves accessibility for screen readers and helps search engines understand the page structure.

Using `` is semantic HTML: it conveys the meaning that the content is a top-level heading. Screen readers can navigate by headings, and search engines use headings to infer content hierarchy. Approach B uses a generic `` with inline styles, which provides no semantic meaning and is less accessible.

Q156. Which of the following best explains why modern best practice separates HTML structure from CSS presentation, as opposed to using tags like `<font>` and `<center>`?

Intermediate
A Separation of concerns makes code cleaner, easier to maintain, and improves accessibility by keeping semantic meaning intact. B Using `<font>` and `<center>` is faster for the browser to render than CSS. C HTML cannot include any styling information, so CSS must always be used separately. D CSS cannot be used to style elements that are defined with semantic HTML tags.
Show answer & explanation

Separation of concerns makes code cleaner, easier to maintain, and improves accessibility by keeping semantic meaning intact.

Separating HTML structure (using semantic tags like ``, ``) from CSS presentation (controlling colors, fonts, layout) follows the principle of separation of concerns. This approach results in cleaner, more maintainable code, and ensures that HTML retains its semantic meaning for accessibility and SEO, while CSS handles…

Q157. Why is it important not to skip heading levels?

Intermediate
Show answer & explanation

—

Focuses on the accessibility impact of skipping levels.

Q158. How do screen readers use heading tags?

Intermediate
Show answer & explanation

—

Connects heading usage to assistive technology.

Q159. What is the impact of headings on SEO?

Intermediate
Show answer & explanation

—

Explains the SEO benefit of proper heading use.

Q160. Can headings be used just to make text larger? Why or why not?

Intermediate
Show answer & explanation

—

Clarifies the separation of structure and style.

Q161. Is it acceptable to nest a heading inside a `<p>` tag? Explain.

Intermediate
Show answer & explanation

—

Tests understanding of block-level element rules.

Q162. What happens if you use headings solely for visual appearance?

Intermediate
Show answer & explanation

—

Explains the negative consequences of misuse.

Q163. How do headings and paragraphs work together to form a web page structure?

Intermediate
Show answer & explanation

—

Tests the combined role of both elements.

Q164. A developer creates a webpage with the following structure: ```html <h1>My Blog</h1> <h2>About Me</h2> <p>I am a web developer.</p> <h3>My Skills</h3> <p>HTML, CSS, JavaScript.</p> <h2>Contact</h2> <p>Email me at example@example.com.</p> ``` Which of the following best describes the relationship between the `<h3>` tag and the `<h2>` tags in this structure?

Intermediate
A The `<h3>` tag is incorrectly placed because it should be an `<h2>` tag. B The `<h3>` tag is a subsection of the `<h1>` tag ("My Blog") only. C The `<h3>` tag is a subsection of the second `<h2>` tag ("Contact"). D The `<h3>` tag is a subsection of the first `<h2>` tag ("About Me").
Show answer & explanation

The `<h3>` tag is a subsection of the first `<h2>` tag ("About Me").

In HTML heading hierarchy, `` represents a subsection under the nearest preceding `` tag. Here, "My Skills" appears after "About Me" and its content, so it is a sub-topic of "About Me." The second `` ("Contact") comes later, so the `` is not under it.

Q165. Consider the following HTML snippet: ```html <p>Welcome to our site.</p> <h2>Services</h2> <p>We offer web design.</p> <h3>Web Design</h3> <p>We create responsive layouts.</p> ``` What is the main structural issue with this snippet?

Intermediate
A The `<p>` tag before the `<h2>` tag is unnecessary and should be removed. B The `<h3>` tag is used without a preceding `<h2>` tag that introduces the section. C The snippet lacks an `<h1>` tag to define the page's main topic. D The `<h2>` tag should be an `<h1>` tag because it is the first heading.
Show answer & explanation

The snippet lacks an `<h1>` tag to define the page's main topic.

Best practice recommends using exactly one `` tag per page to represent the main title or topic. This snippet starts with a paragraph and then uses `` and `` tags, but no `` tag, which breaks the logical heading hierarchy and can confuse both users and search engines about the page's primary subject.

Q166. A student writes the following code: ```html <h2>Section Title</h2> <p>Some text here.</p> <h4>Subsection</h4> <p>More text.</p> ``` Why is this considered poor practice?

Intermediate
A Because there should be a `<h3>` tag before the `<h4>` tag. B Because the `<h4>` tag is too small for a subsection. C Because `<h4>` tags are not allowed after `<h2>` tags. D Because heading levels should not be skipped (from `<h2>` to `<h4>`).
Show answer & explanation

Because heading levels should not be skipped (from `<h2>` to `<h4>`).

Skipping heading levels (e.g., from `` directly to ``) breaks the logical document outline. It confuses screen readers that rely on heading hierarchy for navigation and can mislead search engines about the structure of the content. The correct approach would be to use `` for the subsection.

Q167. Which of the following statements best explains how headings and paragraphs contribute to accessibility?

Intermediate
A Headings provide visual styling, while paragraphs provide content; both are equally important for screen readers. B Paragraphs are more important than headings for accessibility because they contain the main information. C Screen readers use heading tags to create a navigable outline of the page, allowing users to jump between sections, while paragraphs provide the detailed content. D Headings and paragraphs are only useful for visual users; screen readers ignore them.
Show answer & explanation

Screen readers use heading tags to create a navigable outline of the page, allowing users to jump between sections, while paragraphs provide the detailed content.

Screen readers rely on the semantic structure of HTML. Heading tags (`` to ``) create a hierarchical outline that users can navigate by jumping from heading to heading. Paragraphs contain the text content that is read in order. Together, they provide a clear, accessible structure that allows users with visual impairmen…

Q168. A developer wants to make a subheading appear smaller than the main heading but still maintain proper document structure. Which approach is correct?

Intermediate
A Use `<h1>` for the main heading and `<h6>` for the subheading, then use CSS to make the `<h6>` text larger. B Use `<h1>` for the main heading and `<h2>` for the subheading, then use CSS (`font-size`) to adjust the visual size of the `<h2>`. C Use `<p>` with a CSS class that mimics heading styling for the subheading. D Use `<h1>` for both headings, but add a CSS class to make the second one smaller.
Show answer & explanation

Use `<h1>` for the main heading and `<h2>` for the subheading, then use CSS (`font-size`) to adjust the visual size of the `<h2>`.

Headings should reflect the logical hierarchy of content, not visual appearance. The correct structure is to use `` for the main heading and `` for the subheading (since it is a subsection). Then, CSS can be used to adjust the font size of the `` to make it appear smaller if desired. This preserves the semantic meaning…

Q169. How does `<input type="email">` improve the user experience on mobile devices?

Intermediate
Show answer & explanation

—

The keyboard adapts to the input type.

Q170. What is the difference between `<input type="submit">` and `<input type="button">`?

Intermediate
Show answer & explanation

—

Submit triggers form submission; button is inert.

Q171. What happens if you forget to include a submit button in a form?

Intermediate
Show answer & explanation

—

A submit button is essential for sending data.

Q172. Can a form be submitted without a `name` attribute on its inputs? Explain.

Intermediate
Show answer & explanation

—

The name attribute is the key for the data.

Q173. How do checkboxes and radio buttons differ in terms of user selection?

Intermediate
Show answer & explanation

—

Checkboxes are for multiple choices; radio buttons are for single choice.

Q174. What is a common mistake beginners make when creating a submit button?

Intermediate
Show answer & explanation

—

The button type is often confused with submit.

Q175. Why might a developer use `<input type="email">` instead of `<input type="text">` for an email field?

Intermediate
Show answer & explanation

—

The email type improves usability and data quality.

Q176. A developer creates a form with `<input type="text" name="city">` and `<input type="submit">`, but when the form is submitted, the server receives no data. Which of the following is the most likely cause?

Intermediate
A The `<input type="submit">` is missing a `name` attribute. B The `<input type="text">` is missing a `value` attribute. C The `<input type="text">` has a `type` of `text` instead of `email`. D The `<form>` element is missing an `action` attribute.
Show answer & explanation

The `<form>` element is missing an `action` attribute.

Without an `action` attribute, the form still submits (often to the current page), but the server may not process it as expected. However, the most likely reason the server receives *no* data is that the form's submission target is undefined or the form is not properly configured to send data. In many browsers, a missi…

Q177. Consider the following HTML snippet: ```html <form> <input type="radio" name="color" value="red"> Red <input type="radio" name="color" value="blue"> Blue <input type="radio" name="color" value="green"> Green <input type="submit"> </form> ``` If a user selects "Blue" and submits the form, what will be sent to the server?

Intermediate
A `blue` B `color=blue` C `color=blue&color=red&color=green` D Nothing, because radio buttons require a `checked` attribute to send data.
Show answer & explanation

`color=blue`

Radio buttons with the same `name` attribute form a group where only one can be selected at a time. When a radio button is selected and the form is submitted, only the selected radio button's `name=value` pair is sent. Here, `name="color"` and `value="blue"` for the selected option, so the server receives `color=blue`.…

Q178. A developer uses `<input type="button" value="Click">` inside a form expecting it to submit the form. What will happen when the button is clicked?

Intermediate
A The form will submit automatically. B The browser will display an error message. C Nothing happens unless JavaScript is attached to the button. D The button will reset all form fields.
Show answer & explanation

Nothing happens unless JavaScript is attached to the button.

`` creates a generic button that does not have any default behavior. It does not submit the form or reset it. To make it perform an action, you must attach JavaScript (e.g., an `onclick` handler). In contrast, `` automatically submits the form when clicked. Therefore, without JavaScript, clicking this button does nothi…

Q179. Which of the following best explains why `<input type="email">` improves user experience on mobile devices compared to `<input type="text">`?

Intermediate
A It displays a keyboard optimized for email entry, including the '@' symbol and a '.com' key. B It restricts input to only valid email addresses and prevents any typos. C It changes the background color of the input field to indicate it's for email. D It automatically sends the form to the server without a submit button.
Show answer & explanation

It displays a keyboard optimized for email entry, including the '@' symbol and a '.com' key.

On mobile devices, `type="email"` triggers a specialized keyboard that includes keys commonly used in email addresses, such as the '@' symbol and often a '.com' key, making it easier and faster for users to type their email. It does not automatically submit the form, it does not fully prevent typos (though basic valida…

Q180. A student writes the following code: ```html <form> <input type="checkbox" name="subscribe" value="yes"> Subscribe to newsletter <input type="submit"> </form> ``` When the form is submitted with the checkbox unchecked, what data is sent to the server?

Intermediate
A `subscribe=no` B `subscribe=yes` C `subscribe=` (empty value) D No data related to the checkbox is sent.
Show answer & explanation

No data related to the checkbox is sent.

Checkboxes only send their name-value pair to the server when they are checked. If the checkbox is unchecked, it is not included in the form submission data at all. Therefore, when the user submits the form without checking the box, the server receives no data for the `subscribe` field. The other options are incorrect…

Topper level · 20 questions

Q181. A developer writes the following HTML document: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>My Page</title> <script src="large.js"></script> </head> <body> <h1>Welcome</h1> <p>Content</p> </body> </html> ``` The developer wants to improve perceived performance. Which of the following changes to the document structure would MOST effectively reduce the time users wait before seeing visible content, assuming `large.js` is a blocking script?

Advanced
A Remove the `<meta charset="UTF-8">` tag to reduce HTTP requests. B Move the `<script>` tag to the end of the `<body>`, just before `</body>`. C Add a `defer` attribute to the `<script>` tag while keeping it in the `<head>`. D Move the `<link>` tag for CSS into the `<body>` to free up the `<head>` for the script.
Show answer & explanation

Move the `<script>` tag to the end of the `<body>`, just before `</body>`.

By default, a `` tag in the `` blocks HTML parsing and rendering until it is downloaded and executed. Moving the `` to the end of the `` ensures that the browser parses and renders the visible content (the `` and ``) before fetching and running the script, so users see content sooner. The `defer` attribute also works,…

Q182. Consider the following HTML document: ```html <!DOCTYPE html> <html> <head> <title>Test</title> <style> body { background: red; } </style> </head> <body> <p>Hello</p> <script> document.title = "New Title"; </script> </body> </html> ``` A validator reports that the document is malformed. Which of the following is the MOST accurate description of the structural error?

Advanced
A The `<style>` element is not allowed inside the `<head>`; it must be placed in the `<body>`. B The document is missing the `lang` attribute on the `<html>` element, which is required for validity. C The `<script>` element in the `<body>` modifies the `<title>`, which is invalid because the `<title>` is already closed. D The document is actually valid; the validator is incorrect.
Show answer & explanation

The document is actually valid; the validator is incorrect.

The document is structurally valid HTML5. The `` element is allowed inside the `` (and optionally in the `` with scoped styles, but that's a different feature). The `` in the `` can modify the `` via the DOM; this does not violate HTML syntax. The `lang` attribute is recommended for accessibility but is not required fo…

Q183. A developer encounters a webpage that renders differently in Internet Explorer 11 compared to Chrome. The developer inspects the source and finds the first line is: ```html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> ``` The developer wants the page to render consistently in modern browsers using HTML5 standards. Which of the following is the CORRECT change to the document structure?

Advanced
A Remove the DOCTYPE entirely; modern browsers will default to HTML5 mode. B Keep the existing DOCTYPE but add `<!DOCTYPE html>` as a second line to override it. C Replace the DOCTYPE with `<!DOCTYPE html>` and add `<meta charset="UTF-8">` in the `<head>`. D Change the DOCTYPE to `<!DOCTYPE HTML>` and add `lang="en"` to the `<html>` tag.
Show answer & explanation

Replace the DOCTYPE with `<!DOCTYPE html>` and add `<meta charset="UTF-8">` in the `<head>`.

The existing DOCTYPE triggers **quirks mode** or **almost standards mode** in older browsers, causing inconsistent rendering. To get consistent HTML5 standards mode, the DOCTYPE must be `` (case-insensitive). Adding `` is a best practice for character encoding. Adding a second DOCTYPE is invalid; only one DOCTYPE is al…

Q184. A developer writes the following HTML: ```html <!DOCTYPE html> <html lang="en"> <body> <h1>Title</h1> <head> <title>Page Title</title> <link rel="stylesheet" href="style.css"> </head> <p>Content</p> </body> </html> ``` The page loads, but the CSS does not apply and the browser tab shows an empty title. Which of the following BEST explains the behavior?

Advanced
A The `lang="en"` attribute on `<html>` overrides the `<title>` element, causing it to be ignored. B The `<head>` element is a void element and cannot contain child elements; the browser automatically closes it before the `<title>`. C The browser treats the `<head>` as a semantic sectioning element and moves its content to the correct location automatically. D The `<head>` element is placed inside the `<body>`, so the browser ignores the `<title>` and `<link>` tags because they are not in the document's `<head>`.
Show answer & explanation

The `<head>` element is placed inside the `<body>`, so the browser ignores the `<title>` and `<link>` tags because they are not in the document's `<head>`.

In valid HTML, the `` element must be a direct child of `` and must appear before the ``. When the browser encounters `` inside ``, it does not treat it as the document's head; instead, it is parsed as an unknown element in the body. Consequently, the `` and `` are not recognized as metadata, so the title is empty and…

Q185. A developer is building a multilingual website. The page for English users starts with: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Welcome</title> </head> <body> <p>Hello</p> </body> </html> ``` The developer wants to create a Spanish version of the same page. Which of the following changes to the document structure is BOTH necessary and sufficient to ensure the page is correctly interpreted as Spanish by browsers and assistive technologies?

Advanced
A Change the `lang` attribute to `lang="es"` on the `<html>` tag and update the `<title>` and `<p>` content to Spanish. B Only change the `lang` attribute to `lang="es"` on the `<html>` tag; the content language is automatically inferred. C Change the `<meta charset="UTF-8">` to `<meta charset="ISO-8859-1">` to support Spanish characters. D Add a second `<html>` element with `lang="es"` and place the Spanish content inside it.
Show answer & explanation

Change the `lang` attribute to `lang="es"` on the `<html>` tag and update the `<title>` and `<p>` content to Spanish.

The `lang` attribute on the `` element tells the browser and assistive technologies (like screen readers) the primary language of the document. For a Spanish page, `lang="es"` is required. However, the content (title and body text) must also be in Spanish; otherwise, the page would be marked as Spanish but display Engl…

Q186. Consider the following HTML snippet: ```html <article> <h2>Title</h2> <p>Content <strong>important</strong> text.</p> </article> ``` If a developer wants to ensure that the `<strong>` element is semantically correct for conveying strong importance, which of the following best describes the relationship between `<strong>` and `<p>` in this snippet?

Advanced
A The `<strong>` element is a sibling of the `<p>` element because they are both inside `<article>`. B The `<strong>` element is a parent of the `<p>` element because it contains the word 'important'. C The `<strong>` element is a descendant of `<article>` but not directly nested inside `<p>`. D The `<strong>` element is a child of the `<p>` element, and the `<p>` element is a child of the `<article>` element.
Show answer & explanation

The `<strong>` element is a child of the `<p>` element, and the `<p>` element is a child of the `<article>` element.

In the snippet, `` is placed inside the `` element, meaning the `` is the direct parent of ``. The `` is the parent of `` and ``, so `` is a child of `` and a grandchild of ``. Option B correctly identifies this parent-child relationship.

Q187. An HTML document contains the following code: ```html <p>First paragraph <p>Second paragraph</p> ``` What is the most likely outcome when a browser renders this code, and why?

Advanced
A Both paragraphs are displayed correctly because browsers automatically add closing tags for `<p>` elements. B The browser throws an error and refuses to render the page because the first `<p>` is missing its closing tag. C Only 'Second paragraph' is displayed because the missing closing tag causes the first paragraph to be ignored. D The text 'First paragraph' is displayed as a heading because the browser interprets the missing closing tag as a formatting error.
Show answer & explanation

Both paragraphs are displayed correctly because browsers automatically add closing tags for `<p>` elements.

Browsers are forgiving with HTML errors. When a `` tag is opened without a closing tag, the browser implicitly closes it when it encounters the next block-level element (like another ``). Thus, both paragraphs are displayed correctly, though the first `` is technically unclosed. Option A accurately describes this behav…

Q188. Which of the following statements correctly compares the `<b>` tag and the `<strong>` tag in modern HTML, considering both semantics and rendering?

Advanced
A `<b>` is preferred over `<strong>` because it is more widely supported in older browsers. B `<strong>` adds semantic importance to the enclosed text, while `<b>` only applies bold styling without conveying importance. C Both `<b>` and `<strong>` are purely stylistic and have no semantic meaning; they are interchangeable. D `<strong>` is used for visual emphasis only, while `<b>` is used for structural importance.
Show answer & explanation

`<strong>` adds semantic importance to the enclosed text, while `<b>` only applies bold styling without conveying importance.

In modern HTML, `` indicates strong importance or urgency (semantic), whereas `` is a presentational element that draws attention without adding semantic weight. Option B correctly captures this distinction.

Q189. Given the following HTML: ```html <ul> <li>Apples</li> <li>Bananas</li> </ul> ``` If a developer wants to add a third item 'Cherries' after 'Bananas', which of the following correctly demonstrates the proper nesting and tag usage?

Advanced
A ```html <ul> <li>Apples</li> <li>Bananas</li> <li>Cherries</li> </ul> ``` B ```html <ul> <li>Apples</li> <li>Bananas</li> <li>Cherries</li> </ul> ``` C ```html <ul> <li>Apples</li> <li>Bananas</li> <li>Cherries</li> </ul> ``` D ```html <ul> <li>Apples</li> <li>Bananas</li> <li>Cherries</li> </ul> ```
Show answer & explanation

```html <ul> <li>Apples</li> <li>Bananas</li> <li>Cherries</li> </ul> ```

All options appear identical in the JSON, but the correct answer is the one that adds a new `` element inside the ``, properly nested after the existing `` items. Option A (the first) is the correct representation of adding a third list item with proper nesting.

Q190. A developer writes the following HTML: ```html <nav> <a href="/home">Home</a> <a href="/about">About</a> </nav> ``` Which of the following best explains why using `<nav>` for a navigation menu is preferred over using a generic `<div>` with a class like `class="nav"`?

Advanced
A The `<nav>` tag is required by HTML5 for any group of links, whereas a `<div>` would cause a validation error. B The `<nav>` tag is faster to render than a `<div>` because browsers optimize navigation elements. C The `<nav>` tag automatically styles the links as a horizontal menu, while a `<div>` requires additional CSS. D The `<nav>` tag provides semantic meaning, improving accessibility for screen readers and aiding search engines in understanding the page structure.
Show answer & explanation

The `<nav>` tag provides semantic meaning, improving accessibility for screen readers and aiding search engines in understanding the page structure.

Semantic HTML tags like `` convey meaning about the content they enclose. Screen readers can announce a navigation landmark, and search engines can better index the site. A `` with a class provides no such semantic information. Option B correctly highlights these benefits.

Q191. Given the following HTML snippet: ```html <html> <head> <title>My Page</title> </head> <body> <article> <h1>Welcome</h1> <p>This is a paragraph.</p> <img src="photo.jpg" alt="Photo"> </article> </body> </html> ``` Which of the following best describes the relationship between the `<article>` element and the `<img>` element in terms of the Document Object Model (DOM)?

Advanced
A The `<article>` element is a parent of the `<body>` element, and the `<img>` is a child of the `<article>`. B The `<img>` element is a sibling of the `<article>` element because both are inside the `<body>`. C The `<img>` element is a child of the `<article>` element, and the `<article>` element is a descendant of the `<body>` element. D The `<img>` element is a descendant of the `<h1>` element because it appears after it in the source order.
Show answer & explanation

The `<img>` element is a child of the `<article>` element, and the `<article>` element is a descendant of the `<body>` element.

In the DOM tree, `` is a direct child of ``, and `` is a direct child of ``, making `` a child of `` and `` a descendant of ``. The other options incorrectly describe the hierarchical relationships.

Q192. A developer writes the following HTML for a navigation menu: ```html <nav> <ul> <li><a href="/home">Home</a></li> <li><a href="/about">About</a></li> </ul> </nav> ``` Which statement best evaluates the impact of using the `<nav>` element versus a generic `<div>` with the same content, considering accessibility and SEO?

Advanced
A Using `<nav>` improves accessibility but harms SEO because search engines ignore semantic elements. B Using `<nav>` improves SEO but harms accessibility because screen readers cannot parse semantic elements. C Using `<nav>` improves accessibility by allowing screen readers to identify the navigation region, and improves SEO by helping search engines understand the page structure. D Using `<nav>` has no impact on accessibility or SEO because both render the same visually.
Show answer & explanation

Using `<nav>` improves accessibility by allowing screen readers to identify the navigation region, and improves SEO by helping search engines understand the page structure.

Semantic elements like `` provide meaningful structure that assistive technologies use to navigate content (e.g., jumping to navigation), and search engines use to better index the page. The other options incorrectly claim negative or neutral effects.

Q193. Consider the following two approaches to create a red, bold heading: **Approach A:** ```html <h1 style="color: red; font-weight: bold;">Important Heading</h1> ``` **Approach B:** ```html <div style="font-size: 32px; color: red; font-weight: bold;">Important Heading</div> ``` Which statement correctly analyzes the advantages of Approach A over Approach B in terms of modern best practices?

Advanced
A Approach A is better because it uses a heading tag, which provides semantic meaning for accessibility and SEO, while Approach B uses a generic `<div>` that lacks semantic structure. B Both approaches are equally valid because they produce the same visual result, and modern best practices only care about visual appearance. C Approach A is worse because inline styles are discouraged, and Approach B uses a `<div>` which is the recommended element for headings. D Approach B is better because it uses a `<div>` which is more flexible for styling, and the `font-size` property ensures consistent rendering across browsers.
Show answer & explanation

Approach A is better because it uses a heading tag, which provides semantic meaning for accessibility and SEO, while Approach B uses a generic `<div>` that lacks semantic structure.

Using `` provides semantic meaning (it is a top-level heading), which helps screen readers navigate and search engines understand content hierarchy. A `` has no semantic meaning, making Approach B less accessible and SEO-friendly, even if both look similar with inline styles.

Q194. An HTML document contains the following code: ```html <p>This is a <span>highlighted</span> word.</p> ``` A developer argues that the `<span>` element is a block-level element because it is nested inside a `<p>`. Evaluate this claim based on the standard behavior of HTML elements.

Advanced
A The claim is incorrect because `<span>` is a replaced element like `<img>`, and replaced elements are always block-level. B The claim is correct because any element nested inside a block-level element becomes block-level itself. C The claim is incorrect because `<span>` is an inline element by default, regardless of its parent; nesting does not change its display type. D The claim is correct because `<span>` is a block-level element that can contain other block-level elements.
Show answer & explanation

The claim is incorrect because `<span>` is an inline element by default, regardless of its parent; nesting does not change its display type.

The `` element is an inline element by default in HTML. Nesting it inside a block-level element like `` does not change its display type; it remains inline. The other options incorrectly describe `` or the effect of nesting.

Q195. A developer creates an HTML email newsletter with the following structure: ```html <html> <body> <h1>Monthly Update</h1> <p>Welcome to our newsletter.</p> <img src="banner.png" alt="Banner image"> <p>Read more <a href="https://example.com">here</a>.</p> </body> </html> ``` Which of the following best evaluates the potential issues with this HTML when rendered in an email client that does not support external stylesheets?

Advanced
A The `<a>` link will not work in email clients because hyperlinks are not supported in HTML emails. B The `<h1>` and `<p>` elements may have inconsistent styling across email clients, and the `<img>` might not display if images are blocked, but the `alt` attribute provides a fallback. C The email will render correctly because all email clients fully support all HTML elements and attributes. D The `<html>` and `<body>` tags are unnecessary in email HTML and will cause rendering errors in all email clients.
Show answer & explanation

The `<h1>` and `<p>` elements may have inconsistent styling across email clients, and the `<img>` might not display if images are blocked, but the `alt` attribute provides a fallback.

Email clients often have limited CSS support, so headings and paragraphs may appear differently. Images may be blocked by default, but the `alt` attribute provides descriptive text. Hyperlinks are widely supported in email. The `` and `` tags are standard and generally safe.

Q196. A developer is creating a documentation page with the following structure: ```html <h1>API Reference</h1> <h2>Authentication</h2> <p>Details about API keys.</p> <h3>Rate Limits</h3> <p>Maximum 100 requests per hour.</p> <h2>Endpoints</h2> <h4>GET /users</h4> <p>Returns a list of users.</p> ``` Which of the following best describes the structural problem in this snippet?

Advanced
A The `<h4>` tag is used incorrectly because `<h4>` should only appear after `<h3>`. B The `<h1>` tag should be used again for each major section to improve SEO. C The heading hierarchy is broken because `<h4>` is used directly under `<h2>`, skipping `<h3>`. D The `<p>` tags should not follow `<h3>` and `<h4>` directly; they should be wrapped in a `<div>`.
Show answer & explanation

The heading hierarchy is broken because `<h4>` is used directly under `<h2>`, skipping `<h3>`.

The heading hierarchy requires that levels are not skipped. Using `` directly after `` skips ``, breaking the logical structure for screen readers and SEO. The correct approach would be to use `` under `` before using ``.

Q197. Consider the following HTML snippet: ```html <h1>My Portfolio</h1> <h2>Projects</h2> <p>Here are some of my projects.</p> <h3>Project A</h3> <p>Description of Project A.</p> <h3>Project B</h3> <p>Description of Project B.</p> <h2>Skills</h2> <p>I know HTML, CSS, and JavaScript.</p> ``` A developer wants to add a sub-subsection under "Project A" called "Technologies Used" that is less important than the project name but more important than a paragraph. Which of the following is the correct way to maintain proper heading hierarchy?

Advanced
A Use `<h4>Technologies Used</h4>` directly after the `<h3>Project A</h3>`. B Use `<h3>Technologies Used</h3>` because it is a subsection of Project A. C Use `<h2>Technologies Used</h2>` to make it stand out. D Use `<p><strong>Technologies Used</strong></p>` to avoid adding another heading level.
Show answer & explanation

Use `<h4>Technologies Used</h4>` directly after the `<h3>Project A</h3>`.

Since "Technologies Used" is a sub-subsection under "Project A" (which is an ``), the next logical level is ``. Using `` would break the hierarchy by jumping up a level, using `` would imply it is at the same level as "Project A", and using a paragraph with bold loses the semantic meaning of a heading.

Q198. A web page has the following structure: ```html <h1>Online Store</h1> <h2>Electronics</h2> <p>Browse our electronics.</p> <h3>Laptops</h3> <p>High-performance laptops.</p> <h3>Phones</h3> <p>Latest smartphones.</p> <h2>Clothing</h2> <p>Fashion for everyone.</p> <h3>Men's Wear</h3> <p>Shirts and pants.</p> <h4>Formal Shirts</h4> <p>For office wear.</p> <h4>Casual Shirts</h4> <p>For everyday use.</p> ``` A developer wants to add a new section "Accessories" under "Electronics" that is at the same level as "Laptops" and "Phones". Which of the following is the correct HTML to insert?

Advanced
A `<p><strong>Accessories</strong></p><p>Chargers, cases, etc.</p>` B `<h2>Accessories</h2><p>Chargers, cases, etc.</p>` C `<h4>Accessories</h4><p>Chargers, cases, etc.</p>` D `<h3>Accessories</h3><p>Chargers, cases, etc.</p>`
Show answer & explanation

`<h3>Accessories</h3><p>Chargers, cases, etc.</p>`

Since "Accessories" is a subsection under "Electronics" (which is an ``), it should be at the `` level, matching "Laptops" and "Phones". Using `` would make it a top-level section, `` would incorrectly subordinate it, and a paragraph with bold loses semantic meaning.

Q199. A developer writes the following code for a blog post: ```html <h1>10 Tips for Healthy Living</h1> <p>Introduction paragraph.</p> <h2>Tip 1: Exercise Regularly</h2> <p>Details about exercise.</p> <h2>Tip 2: Eat Balanced Meals</h2> <p>Details about diet.</p> <h3>Breakfast Ideas</h3> <p>Oatmeal, eggs, etc.</p> <h2>Tip 3: Stay Hydrated</h2> <p>Drink water.</p> ``` Which of the following statements best evaluates the structural correctness of this snippet?

Advanced
A The structure is correct because `<h3>` is properly nested under `<h2>` and the hierarchy is maintained, even though not all `<h2>` sections have `<h3>` subsections. B The structure is incorrect because the `<h3>` tag "Breakfast Ideas" is a subsection of "Tip 2: Eat Balanced Meals", which is valid, but the hierarchy is broken because there is no `<h3>` under "Tip 1" or "Tip 3". C The structure is correct because all headings follow a logical hierarchy without skipping levels. D The structure is incorrect because `<h3>` should not be used under `<h2>`; it should be a new `<h2>` section.
Show answer & explanation

The structure is correct because `<h3>` is properly nested under `<h2>` and the hierarchy is maintained, even though not all `<h2>` sections have `<h3>` subsections.

The heading hierarchy is maintained: `` is followed by `` for each tip, and `` is used appropriately as a subsection under "Tip 2". It is not required that every `` have an ``; headings only need to reflect the content structure. The hierarchy is not broken because levels are not skipped.

Q200. A student submits the following HTML for a school project: ```html <h1>My Favorite Books</h1> <h2>Fiction</h2> <p>I enjoy fiction books.</p> <h4>Science Fiction</h4> <p>Books about future technology.</p> <h4>Fantasy</h4> <p>Books with magic and mythical creatures.</p> <h2>Non-Fiction</h2> <p>I also read non-fiction.</p> <h3>History</h3> <p>Books about past events.</p> ``` Which of the following best analyzes the issues in this code?

Advanced
A The code has a major issue: `<h2>` should not be used twice; the page should have only one `<h2>`. B The code has two issues: heading levels are skipped (from `<h2>` to `<h4>` under "Fiction") and the hierarchy is inconsistent because `<h3>` is used under "Non-Fiction" while `<h4>` is used under "Fiction". C The only issue is that `<h4>` is used instead of `<h3>` under "Fiction", but otherwise the structure is fine. D The code is correct because `<h4>` and `<h3>` are both valid heading levels and the content is well-organized.
Show answer & explanation

The code has two issues: heading levels are skipped (from `<h2>` to `<h4>` under "Fiction") and the hierarchy is inconsistent because `<h3>` is used under "Non-Fiction" while `<h4>` is used under "Fiction".

Under "Fiction" (an ``), the next logical level should be ``, but the student used ``, skipping ``. Additionally, under "Non-Fiction" (also an ``), the student correctly used ``, creating inconsistency. Both issues break proper heading hierarchy and confuse assistive technologies.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages