Can we have multiple itemprop's on single element for microdata tagging

血红的双手。 提交于 2019-12-10 03:12:25

问题


Can we tag a single html element with multiple "itemprop" properties? I'm working on something for micro data tagging.(schema.org)

<asp:HyperLink ID="hlnk10" itemprop="url" itemprop ="manufacturer"  runat="server">     </asp:HyperLink>

The hyperlink Text contains both properties I want to tag Is this possible as per schema.org standards?

Thanks in advance.


回答1:


My reading of the specification leads me to the conclusion that you can have just one itemprop attribute per element but it can have more than one value.

"Every HTML element may have an itemprop attribute specified... The itemprop attribute, if specified, must have a value that is an unordered set of unique space-separated tokens that are case-sensitive, representing the names of the name-value pairs that it adds. The attribute's value must have at least one token." http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#names:-the-itemprop-attribute

You might try the nu validator or a microdata parser to test your code and make sure you're getting the output you expect.

So instead of <span itemprop="name" itemprop="description"> you would use <span itemprop="name description">

Google's Rich Snippet Testing Tool may not be able to handle multiple itemprop values, yet, though.

I don't know what that asp will generate, but I think you want output more like this: <a href="/" itemprop="url"><span itemprop="manufacturer">The Name</span></a> In order to get access to the text content of the link you add an extra span. The value of an a element will always just be the value of its href attribute. Adding an extra span to get access to the text content of a link is a common pattern.



来源:https://stackoverflow.com/questions/9485711/can-we-have-multiple-itemprops-on-single-element-for-microdata-tagging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!