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.

Updated on: 2026-03-15T21:18:18+05:30

573 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements