将Microdata实施到非HTML5页面 [英] Implement Microdata to a non HTML5 page
问题描述
我想在我的网页上使用Microdata结构(使用Schema.org)。我的网页尚未使用HTML5。
如何实现 itemscope
和 itemtype
标签?当我添加这些时,我得到错误:
itemscope
不是一个有效的属性元素dive
Microdata ,其中包括itemscope和itemtype属性是HTML5工作的一部分,所以没有标准doctype可用于使用具有早期doctype的微数据。您有几个选项,但没有一个特别适合。
-
将您的网页更改为HTML5。这可能是最好的前进方向。 忽略验证错误。验证器只是一个工具来帮助你。微数据的消费者不太可能关心您使用的文档类型。
有一个HTML4.01和RDFa的文档类型
<!DOCTYPE HTML PUBLIC - // W3C // DTD HTML 4.01 + RDFa 1.1 // ENhttp://www.w3.org/ MarkUp / DTD / html401-rdfa11-1.dtd>
和W3C HTML验证程序可以识别这一点。 写下你自己的文档类型定义为HTML4.01 +微数据并验证您的页面。或谷歌,看看是否有其他人已经写了非官方的。
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 elementdive
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.
Change your page to HTML5. This is probably the best way forward.
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.
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.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.
这篇关于将Microdata实施到非HTML5页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!