Html HTML5 元验证
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9655526/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML5 meta Validation
提问by Jesper M?ller
Im trying to make my first HTML5 page but i simply cant get it to validate W3C keeps telling me that i have some errors i my meta tags.
我正在尝试制作我的第一个 HTML5 页面,但我根本无法通过它来验证 W3C 一直告诉我我的元标记有一些错误。
the page in question is http://www.jmphoto.dk/otus/index.html(its an old HTML4 page that i try to use as base/redeo as HTML 5)
有问题的页面是http://www.jmphoto.dk/otus/index.html(它是一个旧的 HTML4 页面,我尝试将其用作 HTML 5 的 base/redeo)
I cant find anny solution to get the following metatags to validate or find anny substitutes for them that will validate
我找不到 anny 解决方案来获取以下元标签来验证或找到 anny 替代品来验证它们
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta last-modified="Thu, 14 Apr 2011 12:17:27 GMT" />
<meta name="distribution" content="Global" />
<meta name="copyright" content="(c) 2012 OTUS" />
I have used most of the weekend trying to find a solution on the net but with no luck so I realy hope somebody smart can help me with this.
我周末的大部分时间都在尝试在网上找到解决方案,但没有运气,所以我真的希望有人能帮助我解决这个问题。
回答by Alohci
OK, let's take the easy one first:
好的,让我们先来个简单的:
<meta last-modified="Thu, 14 Apr 2011 12:17:27 GMT" />
last-modified
is not and has never been a valid attribute of the meta
element. Not sure what is intended here.
last-modified
不是也从来都不是meta
元素的有效属性。不确定这里的目的是什么。
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="Expires" content="0" />
Putting caching instructions into meta tags is not a good idea, because although browsers may read them, proxies won't. For that reason, they are invalid and you should send caching instructions as real HTTP headers.
将缓存指令放入元标记并不是一个好主意,因为尽管浏览器可能会读取它们,但代理不会。因此,它们是无效的,您应该将缓存指令作为真正的 HTTP 标头发送。
<meta name="distribution" content="Global" />
<meta name="copyright" content="(c) 2012 OTUS" />
Neither distribution
nor copyright
are recognized values for the name
attribute of the meta
element. Valid names are described at https://w3c.github.io/html/document-metadata.html#standard-metadata-namesand http://wiki.whatwg.org/wiki/MetaExtensions.
元素的属性既不是distribution
也不copyright
是公认的值。有效名称在https://w3c.github.io/html/document-metadata.html#standard-metadata-names和http://wiki.whatwg.org/wiki/MetaExtensions中描述。name
meta
I recommend dcterms.audience
instead of distribution
and dcterms.rights
dcterms.rightsHolder
instead of copyright
.
我推荐dcterms.audience
而不是distribution
和dcterms.rights
dcterms.rightsHolder
而不是copyright
.
回答by ZZ-bb
Have you read the validator message for invalid tags? It says that those tags contain bad values so I'm guessing they are not allowed. Check these links, read validator messages and see if you can find a list of approved tags and properties for HTML 5. Validator services seem to be experimental since HTML 5 is not in it's final form.
您是否阅读了无效标签的验证器消息?它说这些标签包含错误的值,所以我猜他们是不允许的。检查这些链接,阅读验证器消息,看看您是否可以找到 HTML 5 的已批准标记和属性列表。验证器服务似乎是实验性的,因为 HTML 5 还不是最终形式。
Is the copyright meta tag valid in HTML5?
http://www.impressivewebs.com/understanding-html5-validation/
http://www.impressivewebs.com/understanding-html5-validation/
回答by Khayri R.R. Woulfe
This alternative for meta name="last-modifed"
is validated by W3 Validator as valid HTML5 and probablyrecognized by modern search engines:
meta name="last-modifed"
W3 Validator 将这个替代方案验证为有效的 HTML5,并且可能被现代搜索引擎识别:
<link rel="schema.dcterms" href="http://purl.org/dc/terms/" />
<meta name="dcterms.modified" content="2018-01-26" />
回答by Psion
Instead of
代替
<meta last-modified="Thu, 14 Apr 2011 12:17:27 GMT" />
you need to put
你需要把
<meta http-equiv="last-modified" content="Thu, 14 Apr 2011 12:17:27 GMT" />