Att Script Type
## HTML `` tags.
---
## Quick Example
The following example demonstrates a script with the `type` attribute explicitly defined:
```html
```
---
## Browser Support
The `type` attribute is universally supported by all major modern and legacy web browsers:
* Google Chrome
* Mozilla Firefox
* Microsoft Edge / Internet Explorer
* Safari
* Opera
---
## Definition and Usage
The `type` attribute tells the browser how to interpret and execute the script content.
A Media Type consists of two parts: a **media type** and a **subtype**. For standard JavaScript, the traditional Media Type is `"text/javascript"`.
### HTML 4.01 vs. HTML5
* **In HTML 4.01:** The `type` attribute was **required** for the `
```
---
## Attribute Values
| Value | Description |
| :--- | :--- |
| `MIME_type` | Specifies the Media Type of the script. |
### Common Media Type Values
* **`text/javascript`** (Default): The standard value for JavaScript.
* **`module`**: Introduced in modern JavaScript (ES6). Tells the browser to treat the script as an ES module, enabling `import` and `export` statements.
* **`text/babel`**: Used when writing JSX/ES6+ code that needs to be compiled in the browser by Babel (common in legacy React setups).
* **`application/json`** or **`importmap`**: Used for defining import maps or embedding raw JSON data inside the HTML document.
* **`text/ecmascript`** / **`application/javascript`** / **`application/ecmascript`**: Alternative, older media types for JavaScript (rarely used today).
* **`text/vbscript`**: Used for VBScript (deprecated and only supported in legacy Internet Explorer).
> **Note:** For a complete list of standard media types, refer to the official (https://www.iana.org/assignments/media-types/media-types.xhtml).
---
## Modern Use Cases and Best Practices
### 1. Omitting the Attribute (Standard JavaScript)
For standard JavaScript, simply omit the `type` attribute. It keeps your HTML clean and compliant with modern HTML5 standards.
```html
```
### 2. Using JavaScript Modules (`type="module"`)
When working with modern modular JavaScript, set the type to `module`. This allows you to use native ES imports and automatically defers script execution.
```html
```
### 3. Embedding Data (`type="application/json"`)
You can use the `
```
YouTip