# Bad value “X” for attribute “type” on element “a”: Subtype missing.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-x-for-attribute-type-on-element-a-subtype-missing
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

A MIME type (also called a media type) always follows the format `type/subtype`, such as `text/html`, `application/pdf`, or `image/jpeg`. The "type" part indicates the general category (e.g., `text`, `image`, `application`, `audio`, `video`), and the "subtype" specifies the exact format within that category. When the validator reports "Subtype missing," it means the value you provided either lacks the `/subtype` portion or isn't a valid MIME type structure at all.

A common cause of this error is misunderstanding the purpose of the `type` attribute on `<a>` elements. The `type` attribute is **not** used to change the behavior or appearance of the link (the way `type` works on `<input>` or `<button>` elements). Instead, it serves as an advisory hint to the browser about what kind of resource the link points to. The browser may use this information to adjust its UI — for example, showing a download prompt for `application/pdf` — but it is not required to act on it.

Because of this misunderstanding, developers sometimes write `type="button"` on an `<a>` element, thinking it will make the link behave like a button. The value `button` is not a valid MIME type (it has no subtype), so the validator flags it. If you need a button, use a `<button>` element instead. If you need a styled link that looks like a button, keep the `<a>` element and use CSS for styling.

### Why this matters

- **Standards compliance:** The HTML specification requires the `type` attribute on `<a>` to be a valid MIME type string. An invalid value violates the spec and may be ignored by browsers or cause unexpected behavior.
- **Accessibility and semantics:** Using `type="button"` on a link can create confusion about the element's role. Screen readers and assistive technologies rely on correct semantics to convey meaning to users.
- **Browser behavior:** While browsers are generally forgiving, an invalid `type` value provides no useful information and could interfere with how the browser handles the linked resource.

### How to fix it

1. **If you intended to hint at the linked resource's MIME type**, make sure you provide a complete `type/subtype` value — for example, `application/pdf` rather than just `application`.
2. **If you used `type` to try to style or change the link's behavior**, remove the `type` attribute entirely. Use CSS for visual styling or switch to a more appropriate element like `<button>`.
3. **If you don't need the `type` attribute**, simply remove it. It's entirely optional on `<a>` elements.

## Examples

### Incorrect: missing subtype

```html
<a href="report.pdf" type="application">Download report</a>
```

The value `application` is incomplete — it's missing the subtype portion after the slash.

### Incorrect: not a MIME type at all

```html
<a href="/order.php" type="button">Submit</a>
```

The value `button` is not a MIME type. This often stems from confusing the `type` attribute on `<a>` with the `type` attribute on `<input>` or `<button>`.

### Correct: valid MIME type

```html
<a href="report.pdf" type="application/pdf">Download report</a>
```

```html
<a href="photo.jpeg" type="image/jpeg">See a photo</a>
```

The `type` attribute uses a properly formatted MIME type with both a type and subtype.

### Correct: removing the attribute entirely

```html
<a href="/order.php">Submit</a>
```

If the `type` attribute isn't serving a real purpose, the simplest fix is to remove it.

### Correct: using a button element instead

```html
<button type="submit">Submit</button>
```

If you need actual button behavior (such as submitting a form), use a `<button>` element rather than an `<a>` element with an invalid `type`.
