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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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>`?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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?
BeginnerShow 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.
BeginnerShow answer & explanation
—
These are the essential parts of the HTML skeleton.
Q19. What is the role of the `<html>` element?
BeginnerShow answer & explanation
—
Everything else is nested inside this element.
Q20. What type of information is stored in the `<head>` section?
BeginnerShow answer & explanation
—
The `` is for information about the page, not visible content.
Q21. What is the function of the `<body>` element?
BeginnerShow answer & explanation
—
The `` is where all visible elements go.
Q22. What does the `<meta charset="UTF-8">` tag do?
BeginnerShow 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?
BeginnerShow answer & explanation
—
These are unique structural elements that cannot be repeated.
Q24. What is the relationship between the `<head>` and `<body>` elements?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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 ___.
BeginnerShow 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.
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow answer & explanation
—
The key point is the forward slash in the closing tag.
Q43. What is an HTML element?
BeginnerShow 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.
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow answer & explanation
—
The answer should mention hyperlinks and the `href` attribute.
Q48. What is the purpose of the `<img>` tag?
BeginnerShow answer & explanation
—
The answer should mention embedding images, self-closing nature, and the `src` attribute.
Q49. What do `<ul>` and `<ol>` tags create?
BeginnerShow answer & explanation
—
The answer should distinguish between unordered and ordered lists and mention ``.
Q50. What is the convention for writing tag names in HTML?
BeginnerShow answer & explanation
—
The answer should mention both the convention (lowercase) and the rule (case-insensitive).
Q51. What does HTML stand for?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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>`.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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 ___.
BeginnerShow 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.
BeginnerShow 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?
BeginnerShow answer & explanation
—
Full marks for stating the full form correctly.
Q68. Is HTML a programming language? Explain briefly.
BeginnerShow 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?
BeginnerShow 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.
BeginnerShow 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?
BeginnerShow answer & explanation
—
Full marks for mentioning both accessibility and SEO benefits.
Q72. What are the two main sections inside an `<html>` element?
BeginnerShow answer & explanation
—
Full marks for naming both `` and `` with brief descriptions.
Q73. What does the `<a>` tag do?
BeginnerShow answer & explanation
—
Full marks for stating it creates a link.
Q74. What is the purpose of the `<head>` element?
BeginnerShow 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?
BeginnerShow answer & explanation
—
Full marks for explaining linking between documents.
Q76. Which HTML tag is used for the most important heading?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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>`)?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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).
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow answer & explanation
—
Tests understanding of the paragraph tag and its default rendering.
Q94. How many `<h1>` tags should you use per page and why?
BeginnerShow answer & explanation
—
Reinforces the best practice of a single main heading.
Q95. Do paragraphs have a hierarchy like headings?
BeginnerShow answer & explanation
—
Highlights a key difference between headings and paragraphs.
Q96. What is the best practice for using multiple `<h2>` tags?
BeginnerShow answer & explanation
—
Reinforces that multiple `` tags are acceptable.
Q97. When would you use `<h4>` to `<h6>` tags?
BeginnerShow answer & explanation
—
Covers the usage of lower-level headings.
Q98. Do you need a heading before every paragraph?
BeginnerShow answer & explanation
—
Clarifies the relationship between headings and paragraphs.
Q99. What is the main purpose of using headings in a web page?
BeginnerShow answer & explanation
—
Tests the core purpose of headings.
Q100. Which HTML element is used to group input fields and control form submission?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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">`?
BeginnerShow 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?
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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="___">`.
BeginnerShow 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">`.
BeginnerShow 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.
BeginnerShow 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?
BeginnerShow 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.
BeginnerShow answer & explanation
—
Any three of these are acceptable.
Q118. Why is the `name` attribute important on an input field?
BeginnerShow answer & explanation
—
It labels the data for the server.
Q119. What does `<input type="password">` do differently from `<input type="text">`?
BeginnerShow answer & explanation
—
The password type hides the characters.
Q120. What is the purpose of `<input type="number">`?
BeginnerShow answer & explanation
—
It ensures only numbers are entered.
Q121. What does the `<form>` element look like on a webpage without CSS styling?
BeginnerShow answer & explanation
—
It is a container, not a visual element.
Q122. List two real-world examples of forms on websites.
BeginnerShow 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?
BeginnerShow answer & explanation
—
The name attribute identifies the data.
Building up · 57 questions
Q124. Why is the `<title>` tag important for SEO?
IntermediateShow 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?
IntermediateShow 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>`?
IntermediateShow answer & explanation
—
This prevents JavaScript from blocking the rendering of the page.
Q127. What is quirks mode and what causes it?
IntermediateShow 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?
IntermediateShow answer & explanation
—
For example, `` indicates English.
Q129. What happens if you place `<title>` or `<link>` tags inside the `<body>`?
IntermediateShow answer & explanation
—
These tags belong in the `` section.
Q130. In what order does a browser process an HTML document?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow answer & explanation
—
The answer should explain the parent-child relationship and give a concrete example.
Q137. What is semantic HTML?
IntermediateShow answer & explanation
—
The answer should define semantic HTML and mention its benefits.
Q138. Why is semantic HTML important for accessibility?
IntermediateShow answer & explanation
—
The answer should connect semantic tags to assistive technology use.
Q139. What happens if you forget a closing tag in HTML?
IntermediateShow answer & explanation
—
The answer should explain the practical consequence, not just that it's 'wrong'.
Q140. What is the tree structure of HTML elements?
IntermediateShow 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?
IntermediateShow 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"`?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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)?
IntermediateShow answer & explanation
—
Full marks for describing it as a tree structure and mentioning its use by browsers/scripts.
Q147. What is semantic HTML?
IntermediateShow 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?
IntermediateShow answer & explanation
—
Full marks for mentioning separation of concerns and CSS.
Q149. How does HTML help with web accessibility?
IntermediateShow answer & explanation
—
Full marks for mentioning semantic tags and assistive technologies.
Q150. What is the difference between HTML and CSS?
IntermediateShow answer & explanation
—
Full marks for clearly distinguishing structure (HTML) from presentation (CSS).
Q151. Name three places where HTML is used besides web pages.
IntermediateShow 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?
IntermediateShow 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**?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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>`?
IntermediateShow 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?
IntermediateShow answer & explanation
—
Focuses on the accessibility impact of skipping levels.
Q158. How do screen readers use heading tags?
IntermediateShow answer & explanation
—
Connects heading usage to assistive technology.
Q159. What is the impact of headings on SEO?
IntermediateShow answer & explanation
—
Explains the SEO benefit of proper heading use.
Q160. Can headings be used just to make text larger? Why or why not?
IntermediateShow answer & explanation
—
Clarifies the separation of structure and style.
Q161. Is it acceptable to nest a heading inside a `<p>` tag? Explain.
IntermediateShow answer & explanation
—
Tests understanding of block-level element rules.
Q162. What happens if you use headings solely for visual appearance?
IntermediateShow answer & explanation
—
Explains the negative consequences of misuse.
Q163. How do headings and paragraphs work together to form a web page structure?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow answer & explanation
—
The keyboard adapts to the input type.
Q170. What is the difference between `<input type="submit">` and `<input type="button">`?
IntermediateShow answer & explanation
—
Submit triggers form submission; button is inert.
Q171. What happens if you forget to include a submit button in a form?
IntermediateShow answer & explanation
—
A submit button is essential for sending data.
Q172. Can a form be submitted without a `name` attribute on its inputs? Explain.
IntermediateShow answer & explanation
—
The name attribute is the key for the data.
Q173. How do checkboxes and radio buttons differ in terms of user selection?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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?
IntermediateShow 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">`?
IntermediateShow 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?
IntermediateShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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"`?
AdvancedShow 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)?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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.
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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.
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