The src attribute

src points to the URL of an external resource for the browser to load — an image, script, video, audio, or the document for an iframe.

Applies to

img, script, video, audio, iframe, source, embed, track

Values

An absolute or relative URL to the resource.

Example

<img src="photo.jpg" alt="Description">
<script src="app.js"></script>

Edge cases

  • For an img with several size variants, use srcset alongside src (src is the fallback for browsers without srcset support).
  • An empty src="" on img can, in some browsers, trigger a re-request of the current page as an image — avoid it.

Security

  • An untrusted/arbitrary src for script or iframe is a real risk — only load from trusted domains.

Related tools