Problem
<script type="text/javascript">
/* ... */
</script>
vs.
<script language="Javascript">
/* ... */
</script>
What should be used and why should it be used?
Alternatively, you might skip either of them, as seen in the example code in the jQuery API reference:
<script src="http://code.jquery.com/jquery-latest.js"></script>
Asked by Ricket
Solution #1
For a long time, the language attribute has been deprecated, and it should no longer be utilized.
When the W3C began working on HTML5, they realized that “text/javascript” was the default script type in all browsers, so they made it the default setting. As a result, you don’t need to type.
Omitting type in XHTML 1.0 or HTML 4.01 is considered incorrect. Attempt to validate the following:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script src="http://example.com/test.js"></script>
</head>
<body/>
</html>
The following error will be displayed to you:
So, if you like standards, go ahead and use it. It should have no practical effect, but if in question, go with the specification.
Answered by Matchu
Solution #2
HTML4/XHTML1 requires
<script type="...">...</script>
HTML5 addresses the fact that there is only one scripting language on the internet and allows users to create their own.
<script>...</script>
The latter is compatible with any browser (NN2+) that supports scripting.
Answered by Ms2ger
Solution #3
Within an HTML document, the type attribute is used to specify the MIME type. The type value may be necessary to validate the HTML document, depending on the DOCTYPE you select.
The language element informs the browser about the scripting language you’re using (Javascript vs. VBScript), but it’s not required and has been deprecated, IIRC.
Answered by JasCav
Post is based on https://stackoverflow.com/questions/2267476/html-script-tag-type-or-language-or-omit-both