Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Should I include language="javascript" in my SCRIPT tags?
The language="javascript" attribute in HTML <script> tags is deprecated and unnecessary in modern web development. Since HTML5, JavaScript is the default scripting language for browsers, making this attribute redundant.
Why language="javascript" is No Longer Needed
HTML5 standardized JavaScript as the default scripting language. Modern browsers automatically assume that any <script> tag without a type attribute contains JavaScript code.
Legacy Usage (Deprecated)
In older HTML versions, the language attribute was used to specify the scripting language:
<script language="javascript">
document.write("Hello World!");
</script>
Modern Approach (Recommended)
Simply use the <script> tag without any language attribute:
<script>
document.write("Hello World!");
</script>
Complete HTML Example
<!DOCTYPE html>
<html>
<head>
<title>Modern Script Tag</title>
</head>
<body>
<script>
document.write("Hello World!");
</script>
</body>
</html>
Alternative: Using type Attribute
If you need to specify the script type explicitly, use the type attribute instead:
<script type="text/javascript">
console.log("This is also valid");
</script>
Browser Compatibility
| Approach | HTML5 Support | Legacy Browser Support | Recommendation |
|---|---|---|---|
<script> |
Full | Full | ? Use this |
<script language="javascript"> |
Deprecated | Works but deprecated | ? Avoid |
<script type="text/javascript"> |
Optional | Full | ?? Only if needed |
Conclusion
Omit the language="javascript" attribute in modern HTML. Use plain <script> tags as browsers default to JavaScript automatically. This keeps your code clean and follows current web standards.
