# Bad value X for attribute “type” on element “link”: Expected a token character or “/” but saw “:” instead.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-x-for-attribute-type-on-element-link-expected-a-token-character-or-but-saw-instead
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `type` attribute on a `<link>` element specifies the MIME type of the linked resource. MIME types follow a specific format: a type and subtype separated by a single forward slash, like `text/css`, `image/png`, or `application/json`. They never contain the `://` sequence found in URLs.

This error most commonly occurs when a URL is accidentally placed in the `type` attribute instead of in the `href` attribute, or when the attributes are confused with one another. For example, writing `type="https://example.com/style.css"` triggers this error because the validator encounters the colon in `https:` where it expects a valid MIME type token.

Another common cause is copying `type` values from other contexts (such as XML namespaces or schema references) that use URL-like strings, and mistakenly applying them to the `type` attribute.

### Why this matters

- **Standards compliance**: The HTML specification requires the `type` attribute to contain a valid MIME type. Invalid values violate the spec and may cause browsers to misinterpret or ignore the linked resource.
- **Browser behavior**: Browsers use the `type` attribute as a hint for how to handle the resource. An invalid MIME type could lead the browser to skip loading the resource entirely, causing missing styles, icons, or other assets.
- **Maintainability**: Incorrect attribute values signal to other developers (and automated tools) that something is misconfigured, making the code harder to maintain.

### How to fix it

1. **Check that `type` contains a valid MIME type**, not a URL or other string. Common valid values include `text/css`, `image/png`, `image/x-icon`, `image/svg+xml`, and `application/rss+xml`.
2. **Ensure URLs are in the `href` attribute**, not `type`.
3. **Consider removing `type` entirely.** For stylesheets, modern browsers default to `text/css`, so `type="text/css"` is optional. For many use cases, the `type` attribute can be safely omitted.

## Examples

### ❌ Incorrect: URL used as the `type` value

```html
<link rel="stylesheet" type="https://example.com/style.css">
```

The validator sees the colon in `https:` and reports the error because this is a URL, not a MIME type.

### ❌ Incorrect: Attributes swapped

```html
<link rel="icon" type="https://example.com/favicon.png" href="image/png">
```

Here the `type` and `href` values have been accidentally swapped.

### ✅ Correct: Valid MIME type with proper `href`

```html
<link rel="icon" type="image/png" href="https://example.com/favicon.png">
```

### ✅ Correct: Stylesheet with valid `type`

```html
<link rel="stylesheet" type="text/css" href="/css/style.css">
```

### ✅ Correct: Stylesheet without `type` (also valid)

```html
<link rel="stylesheet" href="/css/style.css">
```

Since browsers default to `text/css` for stylesheets, omitting `type` is perfectly valid and keeps your markup cleaner.

### ✅ Correct: RSS feed link

```html
<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="/feed.xml">
```
