Microdata itemprop causes W3C validator error

After adding Microdata to my pages, I got a lot of errors from the W3C validator complaining about itemprop :

no attribute " itemprop "

From code like this:

 <p itemprop="description">...</p> 

This is my doctype and html tag

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> 

How to fix validator errors?

ps Previously, I also had a validation error for itemscope . But after I changed it to itemscope="itemscope" , the error will be fixed.

+8
xhtml-1.0-strict w3c-validation microdata
source share
4 answers

Documents with HTML 5 plus Microdata used for confirmation successfully, but due to Error No. 14020, the validator has become more stringent, declaring the documents "valid". Your document is valid HTML 5 + Microdata, but is not strictly an HTML 5 document.

You can use http://Validator.nu/ to test HTML 5 + Microdata.

The site associated with Fabian's answer is not the W3C site that it mentions, so I would not trust that there is as much for HTML 5 as I could have for the earlier (before 2000) version of HTML .

The reason you had to change itemscope to itemscope = "itemscope" is because previous browsers and specifications defined incompatible interpretations (sometimes true, sometimes false) of code, such as itemscope (no value), itemscope = "(empty string interpreted as false XPath) and itemscope = "false" (any non-empty string is sometimes interpreted as true). Thus, the statement in the specification that "Values" true "and" false "are not allowed by logical attributes." However, "true "and" false "may appear in certain attribute values ​​because They are allowed for enumerated attributes, such as draggable . See Bullet # 4 for coding booleans .

Workarounds (in another place) for inserting the wrong code with the script may hide this code from checking, but it will not create a document that is more believable than using static HTML code, since the HTML 5 specification is defined in terms of the internal model of the document, and not an external representation. See HTML 5 Specifications focus on the DOM .

+15
source share

OK, here is what I did to make this work with Validator:

Referring to this page: http://www.w3.org/TR/2011/WD-microdata-20110525/

I have included the main page on my page ("wrapper" if you do):

 <div id="layout" itemscope> 

If you have itemscope in the div tag for your page or for a div containing microdata, then the W3C Validator is easy to enjoy.

+4
source share

DOCTYPE must be HTML5 for microdata validation.

 <!DOCTYPE html> <html xmlns:fb="http://www.facebook.com/2008/fbml"> ..... 

It will work with the paragraph tag:

http://www.w3.org/TR/2011/WD-microdata-20110525/

+1
source share

if you just want to remove this tag, you can do this by deleting the tag from the file located in the main root folder

" wp-includes / general-template.php " on line 891

you can simply remove the extra tag.

0
source share

All Articles