How to identify HTML5
Is there anyway to determine whether an HTML file was written in HTML5?
Solution 1:
oversimplified
If it uses an HTML5 doctype, it's HTML5.
<!DOCTYPE html>
Solution 2:
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:
<!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...
Solution 3:
1) Check <!DOCTYPE html>
at the start of the file
<!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.
Solution 4:
If a page uses the HTML5 doctype (<!DOCTYPE html>)
, you can determine it as a html5.