- An HTML element is the complete construct; tags are the markup delimiters used to represent it.
- Most elements have opening and closing tags, while void elements do not have closing tags.
- Attributes configure elements and are normally written in the opening tag.
- Quoting attribute values consistently improves readability and prevents parsing mistakes.
- Boolean attributes are true when present; writing a value such as "false" does not turn them off.
- Proper nesting follows the permitted content model for each element.
- IDs should be unique in a document; class names can be reused.
- HTML parsers may recover from malformed markup, but browser recovery does not make the source conforming.
- Use browser Developer Tools and an HTML validator to detect structural problems.
18. Quiz: HTML Elements, Tags, Attributes and Nesting Rules
Test your understanding with these 10 questions. Each question includes four options, the correct answer, and an explanation for every option. Expand the answer details after choosing your answer.
Scoring suggestion: Award 1 point for each correct answer. A score of 8/10 or higher indicates a good understanding of this lesson. This HTML quiz reveals answers but does not automatically score or save progress unless your course platform adds JavaScript or quiz functionality.
Question 1: What is an HTML element?
- Only the opening tag
- The complete HTML construct, including its tags and content where applicable
- Only an attribute value
- A CSS selector
Correct answer: B
- A — Incorrect: An opening tag is only one part of many HTML elements.
- B — Correct: An element includes the relevant tags and its content, where applicable.
- C — Incorrect: An attribute value is just the value assigned to an attribute.
- D — Incorrect: A CSS selector targets elements for styling; it is not an HTML element.
Question 2: Which is a void element in HTML?
<div><section><img><strong>
Correct answer: C
- A — Incorrect: A div is a non-void element and normally has an end tag.
- B — Incorrect: A section is a non-void element.
- C — Correct: An img element is void and cannot contain child nodes.
- D — Incorrect: A strong element contains content and has an end tag.
Question 3: What does the href attribute usually specify on an anchor element?
- The destination URL of the link
- The font size of the link
- The link's HTML closing tag
- The browser's screen resolution
Correct answer: A
- A — Correct: The href attribute specifies the hyperlink destination.
- B — Incorrect: Font size is generally controlled by CSS.
- C — Incorrect: The closing tag is written as
</a>. - D — Incorrect: href does not configure screen resolution.
Question 4: Which attribute is a Boolean attribute?
placeholderhrefrequiredalt
Correct answer: C
- A — Incorrect: placeholder takes text that describes the expected input.
- B — Incorrect: href takes a URL or other valid link reference.
- C — Correct: required is true when present on a supported form control.
- D — Incorrect: alt provides a text alternative for an image; it is not Boolean.
Question 5: What happens if you write required="false" on a supported input?
- The input becomes optional
- The browser treats the attribute as absent
- The attribute is present, so it is considered true
- The browser automatically deletes the input
Correct answer: C