HTML5 document and itemscope error - html

I am trying to validate my HTML5 document with Microdata, but I am receiving a very strange error and I don't know what to do here:
Line 1, Column 14242: The itemtype attribute must not be specified on elements that do not have an itemscope attribute specified.
…mtype="http://schema.org/Organization"><span itemprop="name">Company…
This is my HTML code:
<span itemtype="http://schema.org/Organization" itemprop="hiringOrganization">
<span itemprop="name">Company</span>
</span>

From the Microdata specification (Working Draft), section "Typed items":
The type for an item is given as the value of an itemtype attribute on the same element as the itemscope attribute.
So it should be:
<span itemscope itemtype="http://schema.org/Organization" itemprop="hiringOrganization">
<span itemprop="name">Company</span>
</span>

Related

SDTT: "A value for the image field is required"

I have this snippet in a LocalBusiness listing (based on this example):
<div itemscope itemtype="http://schema.org/LocalBusiness">
<div itemprop="image" itemscope="" itemtype="http://schema.org/ImageObject">
<img itemprop="contentUrl" src="/images/trouwlocatiefotos/medium/315_24_83_Veranda-005.jpg">
</div>
</div>
But Google's structured data testing tool throws an error:
image
A value for the image field is required.
Why is it throwing the error?
Testing the URL directly: https://search.google.com/structured-data/testing-tool#url=https%3A%2F%2Fwww.wonderweddings.com%2Fweddingvenues%2F315%2Fbeachclub-sunrise
The markup snippet you posted doesn’t give the quoted error. So your actual markup is probably doing things differently.
It seems that your image property isn’t nested under the LocalBusiness item:
Line 396: <div itemscope itemtype="http://schema.org/LocalBusiness">
Line 372: <div itemprop='image' itemscope itemtype='http://schema.org/ImageObject'>
No itemref involved.
So your LocalBusiness item really doesn’t have an image property. Instead, the image property seems to be specified without any parent item (= itemscope), which is invalid.
Google’s SDTT probably ignores this error and parses the ImageObject as a top-level item, which is why it’s listed on its own (next to LocalBusiness and BreadcrumbList).
How to fix this?
If you can’t move the elements to nest them (like in your example snippet), you could make use of Microdata’s itemref attribute:
<div itemscope itemtype="http://schema.org/LocalBusiness" itemref="business-image"></div>
<div itemprop='image' itemscope itemtype='http://schema.org/ImageObject' id="business-image"></div>
Add in snippet
In LocalBusiness schema, Required image, PriceRange field
Properties from Thing - Google returns errors..
Error:
image=A value for the image field is required.
priceRange=The priceRange field is recommended. Please provide a value if available.
Ans: add in code
1.For (image,logo,photo)= Image Object or URL = An image of the item. This can be a URL or a fully described ImageObject.
For priceRange = Text = The price range of the business, for example $$$.
That items mandatory in LocalBusiness

Itemprop errors

I checked my blog-article' page on validator.w3.org and it keeps show this errors:
Error 1:
The **itemprop** attribute was specified, but the element is not a property of any item.
My blog code:
<h1 class="blogtitle entry-title" itemprop="itemReviewed" itemscope itemtype="http://schema.org/Thing">↩
<span itemprop="name">The article title</span>↩
</h1>
Error 2:
The itemprop attribute was specified, but the element is not a property of any item.
The code:
<h1 class="blogtitle entry-title" itemprop="itemReviewed" itemscope itemtype="http://schema.org/Thing">↩
<span itemprop="title">Article title</span>
</h1>
So in that code I have 2 itemprop errors.
Then Error 3:
The itemprop attribute was specified, but the element is not a property of any item.
The code:
<span class="vcard author author_name"><span class="fn">Siteauthors</span></span>
So How Can I solve this errors? I want my page to have no errors, and only these errors still! I read some articles about this "itemtrop" but I didn't understand much!
Any help is welcome!!!!!
You have to explicitly provide a property (and a type for the property). To do so, you need to add an itemtype to your <html> tag.
In your specific instance, you need to change:
<html lang="en-US">
to:
<html lang="en-US" itemscope itemtype="http://schema.org/WebPage">
And it will successfully validate.
In Schema.org, everything is a Thing. Thing has many child types, listed under "More specific Types". Start there and choose the most specific type for your content. In this example, I chose WebPage, but you could choose any type.
Credit to: https://stackoverflow.com/a/29124838/836695

Microdata markup with 'mainEntityOfPage' for Google Article Rich Snippet

The Microdata example of Google’s Article Rich Snippet contains this meta element with Schema.org’s mainEntityOfPage property:
<meta itemscope itemprop="mainEntityOfPage" itemType="https://schema.org/WebPage" itemid="https://google.com/article"/>
When checking it with the Nu Html Checker, I get this error:
Element meta is missing required attribute content.
Adding an empty content attribute seems to solve this error. Is it correct to do this?
The Nu Html Checker is correct, Google’s example is invalid. The content attribute is required if the meta element has an itemprop attribute.
From WHATWG HTML and also HTML 5.1 (W3C Working Draft): "If […] itemprop is specified, then the content attribute must also be specified."
From the old Microdata (W3C Note): "If a meta element has an itemprop attribute, […] the content attribute must be present."
Adding an empty content attribute makes it valid, but there are also other options.
Schema.org’s mainEntityOfPage property expects as value either a URL or a CreativeWork item.
Google’s own documentation for the recommended/required properties for their Article Rich Snippet says that they expect a URL value, but their examples show how to create an item value.
All of the following solutions are fine according to the Google Structured Data Testing Tool. (Some examples use the itemid attribute, which is, strictly speaking, not yet allowed/defined for the Schema.org vocabulary.)
If you want to provide a URL value:
<link itemprop="mainEntityOfPage" href="https://example.com/article" />
Straightforward.
This follows Google’s own recommendation, requires minimal markup, and works in the head as well as the body.
If you have a visible link, you can of course also use an a element.
If you want to provide an item value:
As type you can use CreativeWork or any of its subtypes, like WebPage.
div element + url property
<div itemprop="mainEntityOfPage" itemscope itemtype="http://schema.org/WebPage">
<link itemprop="url" href="https://example.com/article" />
</div>
This creates a WebPage item with a url property. It can only be used in the body.
If you have a visible link, you can of course also use an a element.
meta element with empty content attribute and itemid
<meta itemprop="mainEntityOfPage" content="" itemscope itemtype="http://schema.org/WebPage" itemid="https://example.com/article" />
This is based on Google’s example, but with an empty content attribute to make it valid.
Note that Microdata parsers have to ignore the content attribute in that case, because the itemscope attribute is provided (Microdata W3C Note/WHATWG HTML Microdata: "first matching case"). So the itemprop value will be an item, not a string.
This creates an empty item with an identifier. Works in the head as well as the body. It doesn’t allow to add properties directly to this WebPage item (you’d have to create another item with the same itemid value).
div element with itemid
<div itemprop="mainEntityOfPage" itemscope itemtype="http://schema.org/WebPage" itemid="https://example.com/article">
</div>
This creates an empty item with an identifier. Instead of the meta example, it only works in the body, but therefore allows to add additional properties directly to this WebPage item.
If you already have a WebPage item:
If you already provide a WebPage item on your page, e.g.,
<body itemscope itemtype="http://schema.org/WebPage">
<article itemscope itemtype="http://schema.org/Article">
</article>
</body>
you can make use of it via Microdata’s itemref attribute:
<body itemprop="mainEntityOfPage" itemscope itemtype="http://schema.org/WebPage" id="this-page">
<article itemscope itemtype="http://schema.org/Article" itemref="this-page">
</article>
</body>
combined with one of the methods described above, e.g., with itemid or a url property.
Note that you’d typically use the inverse property mainEntity in such a case, but Google doesn’t document that they’d support it for the Article Rich Snippet, currently.

Is the "content" attribute valid for the <span> tag > if so is it a good practice?

Is the "content" attribute valid for span tag? If so is it a good practice?
I'll be applying microdata (schema.org) on my site pages.
I want to add microdata on some elements of my page.
This is my current code:
<span itemscope itemtype="http://schema.org/Product">
<a itemprop="url" class="list-items" href="/product/286/cryptomate64-usb-cryptographic-token/" title="CryptoMate64 USB Cryptographic Token">
<span itemprop="name">CryptoMate64 USB Cryptographic Token</span>
<span class="hidden">
<span itemprop="productid"/>286</span>
<span itemprop="model" content="ACOS5T-B2-SCZ" />ACOS5T-B2-SCZ</span>
</span>
</a>
</span>
As you can see, I have a div with class "hidden" there because the model and id shouldn't be displayed on the page.
I want to minify the code by doing this:
<span itemscope itemtype="http://schema.org/Product">
<a itemprop="url" class="list-items" href="/product/286/cryptomate64-usb-cryptographic-token/" title="CryptoMate64 USB Cryptographic Token">
<span itemprop="name">CryptoMate64 USB Cryptographic Token</span>
<span itemprop="productid" content="286" /> </span>
<span itemprop="model" content="ACOS5T-B2-SCZ" /> </span>
</a>
</span>
I can use meta instead of span so that the content is not visible. But I think it won't be a good practice since I'll be having a lot of items. What can you suggest? Thanks.
I tested your updated code with Google's richsnippets test tool and it works fine with the content attribute on the span.
However, this isn't good practice since there is no content inside the last 2 spans anyway. It is perfectly appropriate in this case to use metas.
<meta itemprop="productid" content="286">
<meta itemprop="model" content="ACOS5T-B2-SCZ">
No, it’s not valid.
Neither HTML5 nor Microdata define a content attribute for span. (RDFa does, but you are not using it.)
If you want to markup content with Microdata that should not be visible, either
use usual HTML and hide it with CSS, or
use link elements (for URIs) and meta elements (for anything else); both elements are allowed in the body, and typically hidden by default browser stylesheets.
I’d prefer the latter variant (meta/link), but it’s not possible everytime (e.g., if you need to add new items with itemscope).

Itemscope and itemprop at same level

I have a link that looks like this:
<a href="//href" itemscope itemtype="http://schema.org/Product">
<img src="src" itemprop="image">
</a>
I'd like to put itemprop="url" in the <a> tag, but it contains the itemscope for that product. Can I put that at the same level as itemtype=?
Or, do I either need to wrap the whole thing in a div to make it work, or use a <meta> tag for the itemprop="url" microdata? Thanks!
You can have itemprop and itemscope on the same element, but it will mean something different.
In this example, a Product item has the url property:
<div itemscope itemtype="http://schema.org/Product">
…
</div>
In this example, some other item has the url property, and its value is a Product item:
…
(Note for the the latter case: the url value is the Product item, not the URL in the href attribute! So this probably doesn’t make sense for the url property.)
No you don't need another wrapper to do that. You can specify itemprop="url" to the a tag.
This technique called "nested scope"
More about this is available at section 2.2 The basic syntax of this link http://www.w3.org/TR/2011/WD-microdata-20110525/