简体   繁体   中英

Implement Microdata to a non HTML5 page

I want to implement the Microdata structure to my web page (using Schema.org). My web page is not using HTML5 yet.

How do I implement the itemscope and itemtype tags? When I add these I get the error:

itemscope is not a valid attribute of element dive

Microdata, which includes the itemscope and itemtype attributes is part of the HTML5 work so there's no standard doctype available for using microdata with earlier doctypes. You have a few options, but none are particularly palatable.

  1. Change your page to HTML5. This is probably the best way forward.

  2. Ignore the validation errors. The validator is only a tool to help you. The consumers of the microdata are unlikely to care what doctype you are using.

  3. Instead of using microdata, you could use RDFa with your schema.org vocabulary. There is a doctype for HTML4.01 and RDFa <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/html401-rdfa11-1.dtd"> and the W3C HTML validator recognises this.

  4. Write your own document type definition for HTML4.01 + microdata and validate your page against that. Or Google to see if someone else has written an unofficial one already.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM