# The “language” attribute on the “script” element is obsolete. You can safely omit it.

> Canonical HTML version: https://rocketvalidator.com/html-validation/the-language-attribute-on-the-script-element-is-obsolete-you-can-safely-omit-it
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `language` attribute was used in early HTML to specify the scripting language of a `<script>` block, typically set to values like `"JavaScript"` or `"VBScript"`. It was deprecated in HTML 4.01 (in favor of the `type` attribute) and is now fully obsolete in the HTML Living Standard. While browsers still recognize it for backward compatibility, it serves no functional purpose and triggers a validation warning.

The `<script>` element accepts several standard attributes, but the two most common are `type` and `src`. The `type` attribute specifies the MIME type or module type of the script (e.g., `"module"` or `"application/json"`), and `src` points to an external script file. When writing standard JavaScript, you can omit `type` entirely because `"text/javascript"` is the default. The `language` attribute, however, should always be removed — it is not a valid substitute for `type` and has no effect in modern browsers.

## Why this matters

- **Standards compliance:** Using obsolete attributes means your HTML does not conform to the current HTML specification. This can cause validation errors that obscure more important issues in your markup.
- **Code clarity:** The `language` attribute is misleading to developers who may not realize it's non-functional. Removing it keeps your code clean and easier to maintain.
- **Future-proofing:** While browsers currently tolerate the attribute, there is no guarantee they will continue to do so indefinitely. Relying on obsolete features is a maintenance risk.

## How to fix it

Simply remove the `language` attribute from your `<script>` elements. If you're using JavaScript (the vast majority of cases), no replacement is needed. If you need to specify a non-default type, use the `type` attribute instead.

## Examples

### ❌ Obsolete: using the `language` attribute

```html
<script language="JavaScript">
  console.log("Hello, world!");
</script>
```

```html
<script language="JavaScript" src="app.js"></script>
```

### ✅ Fixed: attribute removed

For inline JavaScript, simply omit the attribute:

```html
<script>
  console.log("Hello, world!");
</script>
```

For external scripts, only `src` is needed:

```html
<script src="app.js"></script>
```

### ✅ Using the `type` attribute when needed

If you need to specify a script type — for example, an ES module or a data block — use the standard `type` attribute:

```html
<script type="module" src="app.js"></script>
```

```html
<script type="application/json">
  { "key": "value" }
</script>
```

Note that `type="text/javascript"` is valid but redundant, since JavaScript is the default. You can safely omit it for standard scripts.
