Html 如何识别 HTML5
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8499930/
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
How to identify HTML5
提问by Jayson Tamayo
Is there anyway to determine whether an HTML file was written in HTML5?
有没有办法确定一个 HTML 文件是否是用 HTML5 编写的?
回答by zzzzBov
oversimplified
If it uses an HTML5 doctype, it's HTML5.
过度简化
如果它使用HTML5 doctype,那就是 HTML5。
<!DOCTYPE html>
回答by SuperTron
HTML 5 websites will not have a reference to the DTD in the doctype. Thus, the doctype tag at the top of the file will look like this:
HTML 5 网站不会在文档类型中引用 DTD。因此,文件顶部的 doctype 标记将如下所示:
<!DOCTYPE html>
Instead of one of these:
而不是其中之一:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN""http://www.w3.org/TR/html4/frameset.dtd">
You could also check if any HTML5 tags are used...
您还可以检查是否使用了任何 HTML5 标签...
回答by Mikhail
1) Check <!DOCTYPE html>
at the start of the file
1)<!DOCTYPE html>
在文件开头检查
<!doctype html>
<html>
<head>
<title>A blank HTML5 page</title>
<meta charset="utf-8" />
</head>
<body>
</body>
</html>
2) Detect certain HTML5 only elements such as Canvas.
2) 检测某些仅限 HTML5 的元素,例如 Canvas。
回答by Chamika Sandamal
If a page uses the HTML5 doctype (<!DOCTYPE html>)
, you can determine it as a html5.
如果页面使用 HTML5 doctype (<!DOCTYPE html>)
,您可以将其确定为 html5。