HTML5 Semantic Elements Questions with Answers

25 practice questions on HTML5 Semantic Elements (HTML & CSS) with answers and step-by-step solutions. Try 10 samples below, then practise all 25 free in the AptiNest app.

Sample questions

Question 1Easy

Which element embeds a video natively in HTML5?

  1. <movie>
  2. <media>
  3. <video>
  4. <embed-video>

Answer: C. <video>

Explanation

<video> plays video, with <source> for formats.

Step-by-step solution

  1. <video> plays video, with <source> for formats.
  2. So the answer is: <video>.

Why the other options are wrong

  • A. Not valid.
  • B. Not valid.
  • D. Not valid.

Question 2Easy

Which attribute gives alternative text for an image?

  1. title only
  2. src
  3. longdesc only
  4. alt

Answer: D. alt

Explanation

alt helps screen readers and shows when images fail to load.

Step-by-step solution

  1. alt helps screen readers and shows when images fail to load.
  2. So the answer is: alt.

Why the other options are wrong

  • A. title gives a tooltip.
  • B. src gives the image path.
  • C. longdesc is obsolete.

Question 3Easy

The correct HTML5 doctype is

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
  2. <!DOCTYPE html>
  3. <html5>
  4. <!DOCTYPE html5>

Answer: B. <!DOCTYPE html>

Explanation

HTML5 uses the short <!DOCTYPE html>.

Step-by-step solution

  1. HTML5 uses the short <!DOCTYPE html>.
  2. So the answer is: <!DOCTYPE html>.

Why the other options are wrong

  • A. That is the long HTML 4.01 doctype.
  • C. <html5> is not a doctype.
  • D. html5 is not the right value.

Question 4Easy

Which element is used for the introductory content or navigation links at the top of a page or section?

  1. <head>
  2. <top>
  3. <intro>
  4. <header>

Answer: D. <header>

Explanation

<header> is a semantic container for introductory content.

Step-by-step solution

  1. <header> is a semantic container for introductory content.
  2. So the answer is: <header>.

Why the other options are wrong

  • A. <head> holds metadata.
  • B. <top> is not an element.
  • C. <intro> is not an element.

Question 5Medium

Which meta tag makes pages scale properly on phones?

  1. charset
  2. description
  3. refresh
  4. viewport

Answer: D. viewport

Explanation

<meta name="viewport" content="width=device-width, initial-scale=1"> is the standard.

Step-by-step solution

  1. <meta name="viewport" content="width=device-width, initial-scale=1"> is the standard.
  2. So the answer is: viewport.

Why the other options are wrong

  • A. charset sets encoding.
  • B. description sets the page summary.
  • C. refresh reloads the page.

Question 6Medium

Which attribute prevents form submission if the field is empty?

  1. mandatory
  2. validate
  3. required
  4. notnull

Answer: C. required

Explanation

The required attribute triggers built-in browser validation.

Step-by-step solution

  1. The required attribute triggers built-in browser validation.
  2. So the answer is: required.

Why the other options are wrong

  • A. Not valid HTML.
  • B. Not valid HTML.
  • D. Not valid HTML.

Question 7Medium

Which element is used for content related to, but separate from, the main content such as a sidebar?

  1. <aside>
  2. <article>
  3. <main>
  4. <nav>

Answer: A. <aside>

Explanation

<aside> holds side notes and related links.

Step-by-step solution

  1. <aside> holds side notes and related links.
  2. So the answer is: <aside>.

Why the other options are wrong

  • B. <article> is main content.
  • C. <main> is main content.
  • D. <nav> is for navigation.

Question 8Medium

Which element draws graphics on a web page using JavaScript?

  1. <svg-draw>
  2. <canvas>
  3. <paint>
  4. <graphic>

Answer: B. <canvas>

Explanation

<canvas> provides a bitmap surface for scripts to draw on.

Step-by-step solution

  1. <canvas> provides a bitmap surface for scripts to draw on.
  2. So the answer is: <canvas>.

Why the other options are wrong

  • A. Not valid.
  • C. Not valid.
  • D. Not valid.

Question 9Hard

Custom data attributes in HTML5 start with the prefix

  1. custom-
  2. data-
  3. x-
  4. user-

Answer: B. data-

Explanation

Attributes like data-id can be read in JavaScript through element.dataset.

Step-by-step solution

  1. Attributes like data-id can be read in JavaScript through element.dataset.
  2. So the answer is: data-.

Why the other options are wrong

  • A. Not the prefix.
  • C. Not the prefix.
  • D. Not the prefix.

Question 10Hard

What is the main benefit of semantic elements?

  1. They make pages load instantly
  2. They improve accessibility and SEO
  3. They replace CSS
  4. They encrypt content

Answer: B. They improve accessibility and SEO

Explanation

Semantic tags describe meaning, helping assistive tech and search engines.

Step-by-step solution

  1. Semantic tags describe meaning, helping assistive tech and search engines.
  2. So the answer is: They improve accessibility and SEO.

Why the other options are wrong

  • A. They do not speed up loading.
  • C. They do not replace styling.
  • D. They do not encrypt.

Practise all 25 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all HTML & CSS topics · All topics