Recently first time I had to use microformats and microdata and met following problem. I need to display currency not in ISO-format. As I understood in microdata I could provide actual value in "content" attribute:

<span itemprop="price">123</span> <span itemprop="currency" content="RUB">руб.</span>

In microformats if I do like that:

<span class="price">123 руб.</span>

I'm getting "Price field includes invalid characters" warning in Google structured data testing tool

If like that:

<span class="price">123</span> <span class="currency">руб.</span>

then "Currency should be in ISO 4217 format" warning.

How can I do it in microformats? Do I have to worry about all these warnings?

有帮助吗?

解决方案

First of all, you can't do <span itemprop="currency" content="RUB">руб.</span> in microdata. The content attribute is only valid on a meta element. So you could do <meta itemprop="currency" content="RUB">руб.. Unlike normal <meta> elements, these can appear in the <body> section of the page. However, there's no direct microformat equivalent of this.

But you could also do <data itemprop="currency" value="RUB">руб.</data> to achieve the same thing in microdata, and it seems that the similar <data class="currency" value="RUB">руб.</data> will do the same job in microformats - see http://microformats.org/#time-data - at least in principle, since it's still quite new.

Failing that, I believe that the old way of doing this in microformats was <abbr class="currency" title="RUB">руб.</abbr> but this is horrible semantics and I would heavily discourage it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top