bhazzard
bhazzard

Reputation: 361

Microdata itemprop on form inputs?

I've been learning about HTML5 microdata, and I want to experiment with using them in my app. My app happens to ALWAYS display data as a form. From what I can tell by reading the spec on microdata, it seems that it isn't meant for use with HTML form inputs, is that true?

For example, would the following attributes be valid on an input element:

<input itemprop="fn" type="text" value="Oliver Twist">

I would expect that parsers would want to grab the value attribute of the input field... but it seems that this is not a valid case.

Upvotes: 4

Views: 1236

Answers (2)

linclark
linclark

Reputation: 896

Microdata is meant to make it easier for other developers to scrape the data from your site to reuse it in other applications. For example, marking up your content with microdata makes it easier for Google to process your data and show it in Rich Snippets.

It isn't meant to interact with form processing at all, that's not part of the use case.

Upvotes: 1

Alohci
Alohci

Reputation: 82976

Yes, that appears to be correct. While the itemprop attribute is perfectly valid on input elements, the property value is the textContent of the element, which, since input is a void element, will always be the empty string.

Upvotes: 3

Related Questions