H

Harikesh • 8.04K Points
Tutor III

Q. Which of the following is true if the property value of a name-value pair added by an element with an itemprop attribute is a meta element ?

  • (A) The value is the item created by the element.
  • (B) The value is the value of the element’s value attribute, if it has one, or the empty string otherwise
  • (C) On getting, if the element has a datetime content attribute, the IDL attribute must return that content attribute’s value
  • (D) The value is the element’s textContent.

Explanation by: Official MCQ Buddy

In HTML5 Microdata, when an element has an itemprop attribute, it is used to define a name-value pair for metadata.

If the element is a <meta> element, its value is taken from the content attribute, or it defaults to an empty string if content is not specified.

Example:

<div itemscope itemtype="https://schema.org/Book">
  <meta itemprop="name" content="The Great Gatsby">
</div>
  • Here, "The Great Gatsby" is the value for name because the <meta> element provides it using the content attribute.

Why Other Options Are Incorrect?

(A) The value is the item created by the element.

  • This is true for elements like <div> or <span>, but not for <meta>. <meta> doesn't create an item; it just stores a value.

(C) On getting, if the element has a datetime content attribute, the IDL attribute must return that content attribute’s value.

  • This applies to <time> elements, not <meta>.

(D) The value is the element’s textContent.

  • <meta> elements don’t have visible text content, so this doesn't apply.

Final Answer:

(B) The value is the value of the element’s value attribute, if it has one, or the empty string otherwise.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.