How to identify HTML5

Html

Html Problem Overview


Is there anyway to determine whether an HTML file was written in HTML5?

Html Solutions


Solution 1 - Html

oversimplified
If it uses an HTML5 doctype, it's HTML5.

<!DOCTYPE html>

Solution 2 - Html

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 - Html

  1. Check <!DOCTYPE html> at the start of the file

    A blank HTML5 page

  2. Detect certain HTML5 only elements such as Canvas.

Solution 4 - Html

If a page uses the HTML5 doctype (<!DOCTYPE html>), you can determine it as a html5.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJayson TamayoView Question on Stackoverflow
Solution 1 - HtmlzzzzBovView Answer on Stackoverflow
Solution 2 - HtmlSuperTronView Answer on Stackoverflow
Solution 3 - HtmlMikhailView Answer on Stackoverflow
Solution 4 - HtmlChamika SandamalView Answer on Stackoverflow