**`src`** ("source") is one of the most widely reused attributes in HTML, appearing on any element that embeds an external file directly: images, scripts, iframes, and single-source video/audio. Its value can be an absolute URL (`https://...`), a root-relative path (`/images/photo.jpg`), or a path relative to the current page. For `<video>`/`<audio>` specifically, using `src` directly works for a SINGLE format, whereas nested `<source>` children (a different, related element) let you offer multiple format fallbacks — you generally use one approach or the other, not both together on the same media element.
1Understanding src
`src` ("source") is one of the most widely reused attributes in HTML, appearing on any element that embeds an external file directly: images, scripts, iframes, and single-source video/audio. Its value can be an absolute URL (https://...), a root-relative path (/images/photo.jpg), or a path relative to the current page. For <video>/<audio> specifically, using src directly works for a SINGLE format, whereas nested <source> children (a different, related element) let you offer multiple format fallbacks — you generally use one approach or the other, not both together on the same media element.
A single src attribute on <video>/<audio> is simpler for one guaranteed format (like MP4, which has near-universal support), while multiple <source> children are the better choice when you need format fallbacks for maximum compatibility.
<img src="/logo.png" alt="Company logo">
<iframe src="https://example.com/embed" title="Embedded content"></iframe>2Practical Example
Here is a real-world application of src showing how it is used in production HTML.
<!-- Single src (one format) versus multiple source children (fallback formats) -->
<video src="/clip.mp4" controls></video>
<!-- versus -->
<video controls>
<source src="/clip.mp4" type="video/mp4">
<source src="/clip.webm" type="video/webm">
</video>3Best Practices
Follow these guidelines when working with src:
1. Use absolute URLs for resources on a different domain (like a CDN), root-relative paths for resources on your own site
2. For video/audio needing multiple format fallbacks, use nested <source> elements instead of a single src
3. Double-check src paths carefully — a typo silently results in a broken image/broken embed with no error shown to the user by default
Tip: A single src attribute on <video>/<audio> is simpler for one guaranteed format (like MP4, which has near-universal support), while multiple <source> children are the better choice when you need format fallbacks for maximum compatibility.
<img src="/logo.png" alt="Company logo">
<iframe src="https://example.com/embed" title="Embedded content"></iframe>