简体   繁体   English

将微数据实现到非 HTML5 页面

[英]Implement Microdata to a non HTML5 page

I want to implement the Microdata structure to my web page (using Schema.org).我想在我的网页上实现微数据结构(使用 Schema.org)。 My web page is not using HTML5 yet.我的网页还没有使用 HTML5。

How do I implement the itemscope and itemtype tags?如何实现itemscopeitemtype标签? When I add these I get the error:当我添加这些时,我收到错误:

itemscope is not a valid attribute of element dive itemscope不是元素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.包含 itemscope 和 itemtype 属性的微数据是 HTML5 工作的一部分,因此没有可用于将微数据与早期文档类型一起使用的标准文档类型。 You have a few options, but none are particularly palatable.你有几个选择,但没有一个特别可口。

  1. Change your page to HTML5.将您的页面更改为 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.您可以将 RDFa 与您的 schema.org 词汇表一起使用,而不是使用微数据。 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. HTML4.01 和 RDFa <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/html401-rdfa11-1.dtd">有一个文档类型<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/html401-rdfa11-1.dtd">并且 W3C HTML 验证器可以识别这一点。

  4. Write your own document type definition for HTML4.01 + microdata and validate your page against that.为 HTML4.01 + 微数据编写您自己的文档类型定义,并根据该定义验证您的页面。 Or Google to see if someone else has written an unofficial one already.或者谷歌看看其他人是否已经写了一个非官方的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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