Att Link Type
## HTML <link> type Attribute
The `type` attribute of the `` tag specifies the Internet Media Type (commonly referred to as MIME type) of the linked document or resource.
This attribute helps the browser identify the type of content it is about to fetch, allowing it to determine if it can support and process the resource before downloading it.
---
## Quick Example
In the example below, the `type` attribute indicates that the linked document is an external Cascading Style Sheet (CSS):
```html
```
---
## Browser Support
The `type` attribute is universally supported by all major modern web browsers:
* Google Chrome
* Mozilla Firefox
* Microsoft Edge / Internet Explorer
* Safari
* Opera
---
## Definition and Usage
* **Purpose:** The `type` attribute defines the MIME type of the destination URL specified in the `href` attribute.
* **Dependency:** This attribute should only be used when the `href` attribute is present.
* **Common Value:** The most frequently used MIME type for the `` tag is `"text/css"`, which describes an external stylesheet.
### HTML 4.01 vs. HTML5 Differences
* **HTML 4.01:** The `type` attribute was strictly required when linking stylesheets (`rel="stylesheet"`).
* **HTML5:** The `type` attribute is **optional** for CSS stylesheets. If omitted, modern browsers default to `text/css`. However, explicitly declaring it remains a best practice for clarity and backward compatibility.
---
## Syntax
```html
```
### Attribute Values
| Value | Description |
| :--- | :--- |
| *MIME_type* | Specifies the media type of the linked resource (e.g., `text/css`, `image/x-icon`, `application/manifest+json`). |
> **Note:** For a complete list of standard media types, please refer to the official (https://www.iana.org/assignments/media-types/media-types.xhtml).
---
## Common Practical Examples
### 1. Linking an External CSS Stylesheet
While modern browsers default to CSS, explicitly declaring the MIME type ensures compatibility across legacy environments.
```html
```
### 2. Adding a Favicon
When adding a shortcut icon or favicon to your website, the `type` attribute tells the browser the format of the image (such as `.ico` or `.png`).
```html
```
### 3. Linking a Web App Manifest
For Progressive Web Apps (PWAs), you can link a manifest file using the JSON-specific MIME type.
```html
```
### 4. Linking an RSS Feed
If your website provides a syndication feed, you can specify the XML-based feed type.
```html
```
YouTip