简体   繁体   English

目前有一种方法可以使用HTML5 <meta> 外面的标签 <head> 在WebKit?

[英]Is there currently a way to use HTML5 <meta> tags outside of <head> in WebKit?

I'm trying to use <meta> tags throughout my HTML document to mark-up hidden microdata values, as descriped in Mark Pilgrim's Dive Into HTML 5 . 我正在尝试在整个HTML文档中使用<meta>标记来标记隐藏的微数据值,如Mark Pilgrim的Dive Into HTML 5中所述 However, when my page loads in Chrome (specifically, Chromium 6.0.418.0), I get the following error messages: 但是,当我的页面加载Chrome(特别是Chromium 6.0.418.0)时,我收到以下错误消息:

<meta> is not allowed inside <article>. Moving <meta> into the <head>.
<meta> is not allowed inside <span>. Moving <meta> into the <head>.
<meta> is not allowed inside <div>. Moving <meta> into the <head>.

Is there currently a workaround for this? 目前有解决方法吗? The same thing happens in Firefox 3.6.13, though I am particularly interested in a workaround for WebKit at this time. 同样的事情发生在Firefox 3.6.13中,尽管我现在对WebKit的解决方法特别感兴趣。

More recent versions of WebKit have, like Firefox, an HTML5-compliant parser, and support meta elements outside the head element. 最近的WebKit版本都有,如Firefox,兼容HTML5的解析器,并支持meta外部因素head元素。

I should also note that W3Schools is not related to the W3C, and is well known to publish utter nonsense. 我还应该注意到W3Schools与W3C无关,众所周知,W3Schools完全是胡说八道。 Also, Microdata is still part of HTML, and using it is perfectly fine. 此外,Microdata仍然是HTML的一部分,使用它是完全正常的。 The fact that it is published in a separate draft at the W3C does not change that in any way. 它在W3C的单独草案中发布的事实并没有以任何方式改变它。

Both the HTML Microdata spec (Editor's Draft from 8 July 2011) and the schema.org HTML Microdata规范(2011年7月8日的编辑草案)和schema.org spec 规范 vocabulary by Google, Microsoft, and Yahoo allowed the meta element to be placed into the body as part of semantic data in the microdata format. 词汇由谷歌,微软和雅虎允许meta元被放入身体在微数据格式语义数据的一部分。

As of July 2011, IE 9, FF 5, and Chrome 12 do not throw this error; 截至2011年7月,IE 9,FF 5和Chrome 12不会抛出此错误; Safari 5 still does. Safari 5仍然可以。 (Tested on Win 7) More importantly (IMHO) the W3C's validator does not throw an error. (在Win 7上测试)更重要的是(恕我直言)W3C的验证器不会抛出错误。

Here is a valid example of the meta element in the body: 以下是正文meta元素的有效示例:

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Testing Meta in the Body</title>
    </head>
    <body>
        <div itemscope>
            <meta itemprop="name" content="HTML5 Logo">
            <figure>
                <img src="html5.png">
                <figcaption>The HTML5 Logo</figcaption>
            </figure>
        </div>
    </body>
</html>

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

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