How to correctly specify a Microdata element from a meta tag in the header?

<!DOCTYPE html> <html itemscope itemtype="http://schema.org/WebSite"> <head> <meta itemprop="creator" itemscope itemref="mdFoo"> </head> <body> <div id="mdFoo" itemscope itemtype="http://schema.org/LocalBusiness"> <meta itemprop="name" content="Foo comp"> <meta itemprop="telephone" content="0"> <meta itemprop="legalName" content="Foo comp Ltd"> <meta itemprop="url" content="http://www.foo.com"> <meta itemprop="email" content="info@foo.com"> <div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"> <meta itemprop="streetAddress" content="mystreet"> <meta itemprop="postalCode" content="1233"> <meta itemprop="addressLocality" content="London"> <meta itemprop="addressCountry" content="UK"> </div> </div> </body> </html> 

when checking with Google ( https://google.com/webmasters/markup-tester/ ): "WebSite is not a valid type."

Using https://validator.nu/ gives me "The meta element skips the required attribute content."

Any suggestions on how to fix this?

0
html5 microdata
Mar 18 '16 at 11:18
source share
1 answer

You must specify itemref in the itemscope to which you want to add properties (i.e. the html element in your case). And the element with the corresponding id should receive itemprop .

However, in your case, you do not need the meta element, and you do not need to use itemref :

 <!DOCTYPE html> <html itemscope itemtype="http://schema.org/WebSite"> <head> <title>…</title> </head> <body> <div itemprop="creator" itemscope itemtype="http://schema.org/LocalBusiness"> </div> </body> </html> 

But let's say you use a different itemscope (e.g. for a WebPage element) on the body , in which case you need to use itemref :

 <!DOCTYPE html> <html itemscope itemtype="http://schema.org/WebSite" itemref="mdFoo"> <head> <title>…</title> </head> <body itemscope itemtype="http://schema.org/WebPage"> <div itemprop="creator" itemscope itemtype="http://schema.org/LocalBusiness" id="mdFoo"> </div> </body> </html> 

Now the creator property will be applied to both elements ( WebSite thanks to itemref and WebPage , because its a child).

+2
Mar 18 '16 at 14:48
source share



All Articles