Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
415 views
in Technique[技术] by (71.8m points)

html - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...