# Attribute “src” without an explicit value seen. The attribute may be dropped by IE7.

> Canonical HTML version: https://rocketvalidator.com/html-validation/attribute-src-without-an-explicit-value-seen-the-attribute-may-be-dropped-by-ie7
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `src` attribute appears as a bare name, with no `=` and no value, which leaves the element with an empty URL.

HTML lets you drop the value only on boolean attributes such as `disabled`, `hidden` or `async`, where having the attribute at all is what counts. `src` holds the address of the image, script, frame or media file to load, so it needs one. The parser reads `<img src>` as `<img src="">`, and the validator pairs this warning with an error on the same element saying the `src` value must be non-empty. The IE7 note comes from a time when that browser could drop attributes written this way. IE7 is long gone, but the empty URL still breaks the element.

A browser has nothing to fetch for an empty `src`. An `<img>` loads no image and fires its `error` event, and a `<script>` fires `error` without running. The bare `src` often comes from a lazy-loading script that keeps the real address in `data-src` until the image scrolls into view, or from a template whose image variable printed nothing.

Put the real URL in `src`. The native `loading="lazy"` attribute defers the download without any script. If there's no image to show, leave the `<img>` out of the page instead of printing it with an empty `src`.

## Invalid example

```html
<img src alt="Our team" data-src="/images/team.jpg" class="lazyload">
```

## Valid example

```html
<img src="/images/team.jpg" alt="Our team" loading="lazy">
```
