<!DOCTYPE html>
<
html
>
<
head
>
<
title
>
How to detect HTML 5 is supported
or not in the browser ?
</
title
>
</
head
>
<
body
>
<
h1
style
=
"color: green"
>
GeeksforGeeks
</
h1
>
<
b
>
How to detect HTML5 support
in the browser ?
</
b
>
<
p
>
New input types are one of the
features added in HTML5. <
br
>
Checking for the new input types
means that HTML5 is supported.
</
p
>
<
p
>
Click on the button to check if
the new input types are supported
</
p
>
<
p
>
New input types supported:
<
span
class
=
"output"
></
span
>
</
p
>
<
button
onclick
=
"checkInputType()"
>
Check for input types
</
button
>
<
script
type
=
"text/javascript"
>
function checkInputType() {
let tempElement = document.createElement("input");
tempElement.setAttribute("type", "color");
// Check if the type attribute falls back
// to default text type
if (tempElement.type !== "text")
isSupported = true;
else
isSupported = false;
document.querySelector('.output').textContent
= isSupported;
}
</
script
>
</
body
>
</
html
>