# Bad value “” for attribute “type” on element “source”: Expected a MIME type but saw the empty string.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-for-attribute-type-on-element-source-expected-a-mime-type-but-saw-the-empty-string
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `type` attribute on a `<source>` element must contain a MIME type, so an empty value like `type=""` is invalid.

A `<source>` names one candidate file for its parent `<video>`, `<audio>` or `<picture>` element. The optional `type` attribute gives that file's format, such as `video/mp4`, `audio/mpeg` or `image/avif`, and the browser checks it before downloading anything. A `<video>` or `<audio>` element skips any source whose type it knows it cannot play. A `<picture>` element skips sources with an image type the browser does not support and moves on to the next one, ending at its `<img>`.

An empty `type` gives the browser nothing to check, so either write the file's MIME type or remove the attribute. Removing it is fine for `<video>` and `<audio>`, which find out the format by fetching the file. Inside `<picture>`, keep `type` on any source in a format some browsers can't decode, such as AVIF. Without it, those browsers pick the source anyway and show a broken image. If a template prints `type` on every source, make it print the attribute only when it has a value.

Check the `src` too. A link to a page on a video hosting service is not a media file, and no `type` value will make a `<video>` element play it. Use the service's `<iframe>` embed code for those videos.

## Invalid example

```html
<video controls>
  <source src="intro.webm" type="">
  <source src="intro.mp4" type="">
</video>
```

## Valid example

```html
<video controls>
  <source src="intro.webm" type="video/webm">
  <source src="intro.mp4" type="video/mp4">
</video>
```
