Microdata in XHTML 1.1: there is no attribute “ite

2019-07-28 09:27发布

问题:

I added Microdata to the product pages of my site. That leads to some errors. One of these errors is the following:

there is no attribute "itemprop"

The error is related to this source code line:

<div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">

My Doctype is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

How would it be possible to make the page W3C compliant when keeping the same Doctype?

回答1:

Microdata can only be used in (X)HTML5.

If you want to use the Schema.org vocabulary in XHTML 1.1, you could use RDFa, but this would require changing the DOCTYPE to

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" 
 "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">

(See my answer about differences between Microdata and RDFa.)