Jayson Tamayo
Jayson Tamayo

Reputation: 2811

How to identify HTML5

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

Upvotes: 66

Views: 77060

Answers (4)

SuperTron
SuperTron

Reputation: 4233

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: 48

Chamika Sandamal
Chamika Sandamal

Reputation: 24312

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

Upvotes: 3

Mikhail
Mikhail

Reputation: 8028

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: 179046

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

<!DOCTYPE html>

Upvotes: 75

Related Questions