Jayson Tamayo
Jayson Tamayo

Reputation: 2809

How to identify HTML5

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

Upvotes: 65

Views: 77218

Answers (4)

Chamika Sandamal
Chamika Sandamal

Reputation: 24332

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

Upvotes: 3

SuperTron
SuperTron

Reputation: 4253

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

Upvotes: 49

Mikhail
Mikhail

Reputation: 8038

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.

Upvotes: 3

zzzzBov
zzzzBov

Reputation: 179284

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

<!DOCTYPE html>

Upvotes: 74

Related Questions